using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace GermanApp.Infrastructure.Data.Migrations { /// public partial class AddQuizQuestionTables : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "QuizQuestions", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), LessonId = table.Column(type: "integer", nullable: false), QuestionText = table.Column(type: "character varying(2000)", maxLength: 2000, nullable: false), Type = table.Column(type: "integer", nullable: false), CorrectAnswer = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: true), Difficulty = table.Column(type: "integer", nullable: false, defaultValue: 3), Order = table.Column(type: "integer", nullable: false, defaultValue: 1), IsActive = table.Column(type: "boolean", nullable: false, defaultValue: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => { table.PrimaryKey("PK_QuizQuestions", x => x.Id); table.ForeignKey( name: "FK_QuizQuestions_Lessons_LessonId", column: x => x.LessonId, principalTable: "Lessons", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "QuizOptions", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), QuizQuestionId = table.Column(type: "integer", nullable: false), Text = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: false), IsCorrect = table.Column(type: "boolean", nullable: false, defaultValue: false), Order = table.Column(type: "integer", nullable: false, defaultValue: 1) }, constraints: table => { table.PrimaryKey("PK_QuizOptions", x => x.Id); table.ForeignKey( name: "FK_QuizOptions_QuizQuestions_QuizQuestionId", column: x => x.QuizQuestionId, principalTable: "QuizQuestions", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_QuizOptions_QuizQuestionId_Order", table: "QuizOptions", columns: new[] { "QuizQuestionId", "Order" }, unique: true); migrationBuilder.CreateIndex( name: "IX_QuizQuestions_LessonId_Order", table: "QuizQuestions", columns: new[] { "LessonId", "Order" }, unique: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "QuizOptions"); migrationBuilder.DropTable( name: "QuizQuestions"); } } }