73 lines
3.2 KiB
C#
73 lines
3.2 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace DramaLing.Api.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddFlashcardReviewTable : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "flashcard_reviews",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<Guid>(type: "TEXT", nullable: false),
|
|
flashcard_id = table.Column<Guid>(type: "TEXT", nullable: false),
|
|
user_id = table.Column<Guid>(type: "TEXT", nullable: false),
|
|
success_count = table.Column<int>(type: "INTEGER", nullable: false),
|
|
next_review_date = table.Column<DateTime>(type: "TEXT", nullable: false),
|
|
last_review_date = table.Column<DateTime>(type: "TEXT", nullable: true),
|
|
last_success_date = table.Column<DateTime>(type: "TEXT", nullable: true),
|
|
total_skip_count = table.Column<int>(type: "INTEGER", nullable: false),
|
|
total_wrong_count = table.Column<int>(type: "INTEGER", nullable: false),
|
|
total_correct_count = table.Column<int>(type: "INTEGER", nullable: false),
|
|
created_at = table.Column<DateTime>(type: "TEXT", nullable: false),
|
|
updated_at = table.Column<DateTime>(type: "TEXT", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_flashcard_reviews", x => x.id);
|
|
table.ForeignKey(
|
|
name: "FK_flashcard_reviews_flashcards_flashcard_id",
|
|
column: x => x.flashcard_id,
|
|
principalTable: "flashcards",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_flashcard_reviews_user_profiles_user_id",
|
|
column: x => x.user_id,
|
|
principalTable: "user_profiles",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_flashcard_reviews_flashcard_id_user_id",
|
|
table: "flashcard_reviews",
|
|
columns: new[] { "flashcard_id", "user_id" },
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_FlashcardReviews_NextReviewDate",
|
|
table: "flashcard_reviews",
|
|
column: "next_review_date");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_FlashcardReviews_UserId_NextReviewDate",
|
|
table: "flashcard_reviews",
|
|
columns: new[] { "user_id", "next_review_date" });
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "flashcard_reviews");
|
|
}
|
|
}
|
|
}
|