using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace DramaLing.Api.Migrations { /// public partial class AddStudyCardAndTestResult : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "CompletedCards", table: "study_sessions", type: "INTEGER", nullable: false, defaultValue: 0); migrationBuilder.AddColumn( name: "CompletedTests", table: "study_sessions", type: "INTEGER", nullable: false, defaultValue: 0); migrationBuilder.AddColumn( name: "CurrentCardIndex", table: "study_sessions", type: "INTEGER", nullable: false, defaultValue: 0); migrationBuilder.AddColumn( name: "CurrentTestType", table: "study_sessions", type: "TEXT", maxLength: 50, nullable: true); migrationBuilder.AddColumn( name: "Status", table: "study_sessions", type: "INTEGER", nullable: false, defaultValue: 0); migrationBuilder.AddColumn( name: "TotalTests", table: "study_sessions", type: "INTEGER", nullable: false, defaultValue: 0); migrationBuilder.CreateTable( name: "study_cards", columns: table => new { Id = table.Column(type: "TEXT", nullable: false), StudySessionId = table.Column(type: "TEXT", nullable: false), FlashcardId = table.Column(type: "TEXT", nullable: false), Word = table.Column(type: "TEXT", maxLength: 100, nullable: false), PlannedTestsJson = table.Column(type: "TEXT", nullable: false), Order = table.Column(type: "INTEGER", nullable: false), IsCompleted = table.Column(type: "INTEGER", nullable: false), StartedAt = table.Column(type: "TEXT", nullable: false), CompletedAt = table.Column(type: "TEXT", nullable: true), PlannedTests = table.Column(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(type: "TEXT", nullable: false), StudyCardId = table.Column(type: "TEXT", nullable: false), TestType = table.Column(type: "TEXT", maxLength: 50, nullable: false), IsCorrect = table.Column(type: "INTEGER", nullable: false), UserAnswer = table.Column(type: "TEXT", nullable: true), ConfidenceLevel = table.Column(type: "INTEGER", nullable: true), ResponseTimeMs = table.Column(type: "INTEGER", nullable: false), CompletedAt = table.Column(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"); } /// 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"); } } }