dramaling-vocab-learning/backend/DramaLing.Api/Migrations/20250930081940_FixFlashcard...

429 lines
17 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DramaLing.Api.Migrations
{
/// <inheritdoc />
public partial class FixFlashcardColumnNaming : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_pronunciation_assessments_study_sessions_study_session_id",
table: "pronunciation_assessments");
migrationBuilder.DropTable(
name: "study_records");
migrationBuilder.DropTable(
name: "test_results");
migrationBuilder.DropTable(
name: "study_cards");
migrationBuilder.DropTable(
name: "study_sessions");
migrationBuilder.DropIndex(
name: "IX_PronunciationAssessment_Session",
table: "pronunciation_assessments");
migrationBuilder.DropColumn(
name: "study_session_id",
table: "pronunciation_assessments");
migrationBuilder.DropColumn(
name: "FilledQuestionText",
table: "flashcards");
migrationBuilder.DropColumn(
name: "LastQuestionType",
table: "flashcards");
migrationBuilder.DropColumn(
name: "Repetitions",
table: "flashcards");
migrationBuilder.DropColumn(
name: "ReviewHistory",
table: "flashcards");
migrationBuilder.DropColumn(
name: "Synonyms",
table: "flashcards");
migrationBuilder.DropColumn(
name: "easiness_factor",
table: "flashcards");
migrationBuilder.DropColumn(
name: "interval_days",
table: "flashcards");
migrationBuilder.DropColumn(
name: "last_reviewed_at",
table: "flashcards");
migrationBuilder.DropColumn(
name: "mastery_level",
table: "flashcards");
migrationBuilder.DropColumn(
name: "next_review_date",
table: "flashcards");
migrationBuilder.DropColumn(
name: "times_correct",
table: "flashcards");
migrationBuilder.DropColumn(
name: "times_reviewed",
table: "flashcards");
migrationBuilder.RenameColumn(
name: "Word",
table: "flashcards",
newName: "word");
migrationBuilder.RenameColumn(
name: "Translation",
table: "flashcards",
newName: "translation");
migrationBuilder.RenameColumn(
name: "Pronunciation",
table: "flashcards",
newName: "pronunciation");
migrationBuilder.RenameColumn(
name: "Example",
table: "flashcards",
newName: "example");
migrationBuilder.RenameColumn(
name: "Definition",
table: "flashcards",
newName: "definition");
migrationBuilder.AlterColumn<string>(
name: "definition",
table: "flashcards",
type: "TEXT",
nullable: true,
oldClrType: typeof(string),
oldType: "TEXT");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "word",
table: "flashcards",
newName: "Word");
migrationBuilder.RenameColumn(
name: "translation",
table: "flashcards",
newName: "Translation");
migrationBuilder.RenameColumn(
name: "pronunciation",
table: "flashcards",
newName: "Pronunciation");
migrationBuilder.RenameColumn(
name: "example",
table: "flashcards",
newName: "Example");
migrationBuilder.RenameColumn(
name: "definition",
table: "flashcards",
newName: "Definition");
migrationBuilder.AddColumn<Guid>(
name: "study_session_id",
table: "pronunciation_assessments",
type: "TEXT",
nullable: true);
migrationBuilder.AlterColumn<string>(
name: "Definition",
table: "flashcards",
type: "TEXT",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "TEXT",
oldNullable: true);
migrationBuilder.AddColumn<string>(
name: "FilledQuestionText",
table: "flashcards",
type: "TEXT",
maxLength: 1000,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "LastQuestionType",
table: "flashcards",
type: "TEXT",
maxLength: 50,
nullable: true);
migrationBuilder.AddColumn<int>(
name: "Repetitions",
table: "flashcards",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<string>(
name: "ReviewHistory",
table: "flashcards",
type: "TEXT",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Synonyms",
table: "flashcards",
type: "TEXT",
maxLength: 2000,
nullable: true);
migrationBuilder.AddColumn<float>(
name: "easiness_factor",
table: "flashcards",
type: "REAL",
nullable: false,
defaultValue: 0f);
migrationBuilder.AddColumn<int>(
name: "interval_days",
table: "flashcards",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<DateTime>(
name: "last_reviewed_at",
table: "flashcards",
type: "TEXT",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "mastery_level",
table: "flashcards",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<DateTime>(
name: "next_review_date",
table: "flashcards",
type: "TEXT",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<int>(
name: "times_correct",
table: "flashcards",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "times_reviewed",
table: "flashcards",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "study_sessions",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
user_id = table.Column<Guid>(type: "TEXT", nullable: false),
average_response_time_ms = table.Column<int>(type: "INTEGER", nullable: false),
CompletedCards = table.Column<int>(type: "INTEGER", nullable: false),
CompletedTests = table.Column<int>(type: "INTEGER", nullable: false),
correct_count = table.Column<int>(type: "INTEGER", nullable: false),
CurrentCardIndex = table.Column<int>(type: "INTEGER", nullable: false),
CurrentTestType = table.Column<string>(type: "TEXT", maxLength: 50, nullable: true),
duration_seconds = table.Column<int>(type: "INTEGER", nullable: false),
ended_at = table.Column<DateTime>(type: "TEXT", nullable: true),
session_type = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false),
started_at = table.Column<DateTime>(type: "TEXT", nullable: false),
Status = table.Column<int>(type: "INTEGER", nullable: false),
total_cards = table.Column<int>(type: "INTEGER", nullable: false),
TotalTests = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_study_sessions", x => x.Id);
table.ForeignKey(
name: "FK_study_sessions_user_profiles_user_id",
column: x => x.user_id,
principalTable: "user_profiles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "study_cards",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
FlashcardId = table.Column<Guid>(type: "TEXT", nullable: false),
StudySessionId = table.Column<Guid>(type: "TEXT", nullable: false),
CompletedAt = table.Column<DateTime>(type: "TEXT", nullable: true),
IsCompleted = table.Column<bool>(type: "INTEGER", nullable: false),
Order = table.Column<int>(type: "INTEGER", nullable: false),
PlannedTests = table.Column<string>(type: "TEXT", nullable: false),
PlannedTestsJson = table.Column<string>(type: "TEXT", nullable: false),
StartedAt = table.Column<DateTime>(type: "TEXT", nullable: false),
Word = table.Column<string>(type: "TEXT", maxLength: 100, 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: "study_records",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
flashcard_id = table.Column<Guid>(type: "TEXT", nullable: false),
session_id = table.Column<Guid>(type: "TEXT", nullable: false),
user_id = table.Column<Guid>(type: "TEXT", nullable: false),
is_correct = table.Column<bool>(type: "INTEGER", nullable: false),
NewEasinessFactor = table.Column<float>(type: "REAL", nullable: false),
NewIntervalDays = table.Column<int>(type: "INTEGER", nullable: false),
NewRepetitions = table.Column<int>(type: "INTEGER", nullable: false),
NextReviewDate = table.Column<DateTime>(type: "TEXT", nullable: false),
PreviousEasinessFactor = table.Column<float>(type: "REAL", nullable: false),
PreviousIntervalDays = table.Column<int>(type: "INTEGER", nullable: false),
PreviousRepetitions = table.Column<int>(type: "INTEGER", nullable: false),
quality_rating = table.Column<int>(type: "INTEGER", nullable: false),
response_time_ms = table.Column<int>(type: "INTEGER", nullable: true),
studied_at = table.Column<DateTime>(type: "TEXT", nullable: false),
study_mode = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false),
user_answer = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_study_records", x => x.Id);
table.ForeignKey(
name: "FK_study_records_flashcards_flashcard_id",
column: x => x.flashcard_id,
principalTable: "flashcards",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_study_records_study_sessions_session_id",
column: x => x.session_id,
principalTable: "study_sessions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_study_records_user_profiles_user_id",
column: x => x.user_id,
principalTable: "user_profiles",
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),
CompletedAt = table.Column<DateTime>(type: "TEXT", nullable: false),
ConfidenceLevel = table.Column<int>(type: "INTEGER", nullable: true),
IsCorrect = table.Column<bool>(type: "INTEGER", nullable: false),
ResponseTimeMs = table.Column<int>(type: "INTEGER", nullable: false),
TestType = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false),
UserAnswer = table.Column<string>(type: "TEXT", nullable: true)
},
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_PronunciationAssessment_Session",
table: "pronunciation_assessments",
column: "study_session_id");
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_study_records_flashcard_id",
table: "study_records",
column: "flashcard_id");
migrationBuilder.CreateIndex(
name: "IX_study_records_session_id",
table: "study_records",
column: "session_id");
migrationBuilder.CreateIndex(
name: "IX_StudyRecord_UserCard_TestType_Unique",
table: "study_records",
columns: new[] { "user_id", "flashcard_id", "study_mode" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_study_sessions_user_id",
table: "study_sessions",
column: "user_id");
migrationBuilder.CreateIndex(
name: "IX_test_results_StudyCardId",
table: "test_results",
column: "StudyCardId");
migrationBuilder.AddForeignKey(
name: "FK_pronunciation_assessments_study_sessions_study_session_id",
table: "pronunciation_assessments",
column: "study_session_id",
principalTable: "study_sessions",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
}
}
}