163 lines
6.2 KiB
C#
163 lines
6.2 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace DramaLing.Api.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddStudyCardAndTestResult : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "CompletedCards",
|
|
table: "study_sessions",
|
|
type: "INTEGER",
|
|
nullable: false,
|
|
defaultValue: 0);
|
|
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "CompletedTests",
|
|
table: "study_sessions",
|
|
type: "INTEGER",
|
|
nullable: false,
|
|
defaultValue: 0);
|
|
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "CurrentCardIndex",
|
|
table: "study_sessions",
|
|
type: "INTEGER",
|
|
nullable: false,
|
|
defaultValue: 0);
|
|
|
|
migrationBuilder.AddColumn<string>(
|
|
name: "CurrentTestType",
|
|
table: "study_sessions",
|
|
type: "TEXT",
|
|
maxLength: 50,
|
|
nullable: true);
|
|
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "Status",
|
|
table: "study_sessions",
|
|
type: "INTEGER",
|
|
nullable: false,
|
|
defaultValue: 0);
|
|
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "TotalTests",
|
|
table: "study_sessions",
|
|
type: "INTEGER",
|
|
nullable: false,
|
|
defaultValue: 0);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "study_cards",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "TEXT", nullable: false),
|
|
StudySessionId = table.Column<Guid>(type: "TEXT", nullable: false),
|
|
FlashcardId = table.Column<Guid>(type: "TEXT", nullable: false),
|
|
Word = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
|
|
PlannedTestsJson = table.Column<string>(type: "TEXT", nullable: false),
|
|
Order = table.Column<int>(type: "INTEGER", nullable: false),
|
|
IsCompleted = table.Column<bool>(type: "INTEGER", nullable: false),
|
|
StartedAt = table.Column<DateTime>(type: "TEXT", nullable: false),
|
|
CompletedAt = table.Column<DateTime>(type: "TEXT", nullable: true),
|
|
PlannedTests = table.Column<string>(type: "TEXT", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_study_cards", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_study_cards_flashcards_FlashcardId",
|
|
column: x => x.FlashcardId,
|
|
principalTable: "flashcards",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_study_cards_study_sessions_StudySessionId",
|
|
column: x => x.StudySessionId,
|
|
principalTable: "study_sessions",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "test_results",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "TEXT", nullable: false),
|
|
StudyCardId = table.Column<Guid>(type: "TEXT", nullable: false),
|
|
TestType = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false),
|
|
IsCorrect = table.Column<bool>(type: "INTEGER", nullable: false),
|
|
UserAnswer = table.Column<string>(type: "TEXT", nullable: true),
|
|
ConfidenceLevel = table.Column<int>(type: "INTEGER", nullable: true),
|
|
ResponseTimeMs = table.Column<int>(type: "INTEGER", nullable: false),
|
|
CompletedAt = table.Column<DateTime>(type: "TEXT", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_test_results", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_test_results_study_cards_StudyCardId",
|
|
column: x => x.StudyCardId,
|
|
principalTable: "study_cards",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_study_cards_FlashcardId",
|
|
table: "study_cards",
|
|
column: "FlashcardId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_study_cards_StudySessionId",
|
|
table: "study_cards",
|
|
column: "StudySessionId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_test_results_StudyCardId",
|
|
table: "test_results",
|
|
column: "StudyCardId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "test_results");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "study_cards");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "CompletedCards",
|
|
table: "study_sessions");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "CompletedTests",
|
|
table: "study_sessions");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "CurrentCardIndex",
|
|
table: "study_sessions");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "CurrentTestType",
|
|
table: "study_sessions");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "Status",
|
|
table: "study_sessions");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "TotalTests",
|
|
table: "study_sessions");
|
|
}
|
|
}
|
|
}
|