using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql { /// public partial class OtherExamResults : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "OtherExamBatches", columns: table => new { Id = table.Column(type: "char(36)", nullable: false), Name = table.Column(type: "varchar(150)", maxLength: 150, nullable: false), Organizer = table.Column(type: "varchar(150)", maxLength: 150, nullable: true), ExamDate = table.Column(type: "date", nullable: false), MetricKind = table.Column(type: "int", nullable: false), MaxScore = table.Column(type: "decimal(8,2)", precision: 8, scale: 2, nullable: true), LevelOptions = table.Column(type: "varchar(500)", maxLength: 500, nullable: true), Status = table.Column(type: "int", nullable: false), PublicationCount = table.Column(type: "int", nullable: false), PublishedAt = table.Column(type: "datetime(6)", nullable: true), CreatedAt = table.Column(type: "datetime(6)", nullable: false), UpdatedAt = table.Column(type: "datetime(6)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_OtherExamBatches", x => x.Id); }) .Annotation("MySQL:Charset", "utf8mb4"); migrationBuilder.CreateTable( name: "OtherExamResults", columns: table => new { Id = table.Column(type: "char(36)", nullable: false), OtherExamBatchId = table.Column(type: "char(36)", nullable: false), StudentId = table.Column(type: "char(36)", nullable: false), AttemptNumber = table.Column(type: "int", nullable: false), Score = table.Column(type: "decimal(8,2)", precision: 8, scale: 2, nullable: true), Level = table.Column(type: "varchar(50)", maxLength: 50, nullable: true), IsPassed = table.Column(type: "tinyint(1)", nullable: true), Notes = table.Column(type: "varchar(500)", maxLength: 500, nullable: true), CreatedAt = table.Column(type: "datetime(6)", nullable: false), UpdatedAt = table.Column(type: "datetime(6)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_OtherExamResults", x => x.Id); table.ForeignKey( name: "FK_OtherExamResults_OtherExamBatches_OtherExamBatchId", column: x => x.OtherExamBatchId, principalTable: "OtherExamBatches", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_OtherExamResults_Students_StudentId", column: x => x.StudentId, principalTable: "Students", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }) .Annotation("MySQL:Charset", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_OtherExamBatches_Status_ExamDate", table: "OtherExamBatches", columns: new[] { "Status", "ExamDate" }); migrationBuilder.CreateIndex( name: "IX_OtherExamResults_OtherExamBatchId_StudentId_AttemptNumber", table: "OtherExamResults", columns: new[] { "OtherExamBatchId", "StudentId", "AttemptNumber" }, unique: true); migrationBuilder.CreateIndex( name: "IX_OtherExamResults_StudentId_OtherExamBatchId", table: "OtherExamResults", columns: new[] { "StudentId", "OtherExamBatchId" }); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "OtherExamResults"); migrationBuilder.DropTable( name: "OtherExamBatches"); } } }