using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql { /// public partial class GraduationAudits : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "GraduationAuditBatches", columns: table => new { Id = table.Column(type: "char(36)", nullable: false), Name = table.Column(type: "varchar(120)", maxLength: 120, nullable: false), GraduationYear = table.Column(type: "int", nullable: false), EnrollmentYear = table.Column(type: "int", nullable: false), Status = table.Column(type: "int", nullable: false), Notes = table.Column(type: "varchar(500)", maxLength: 500, nullable: true), CalculatedAt = table.Column(type: "datetime(6)", nullable: true), 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_GraduationAuditBatches", x => x.Id); }) .Annotation("MySQL:Charset", "utf8mb4"); migrationBuilder.CreateTable( name: "GraduationAuditResults", columns: table => new { Id = table.Column(type: "char(36)", nullable: false), GraduationAuditBatchId = table.Column(type: "char(36)", nullable: false), StudentId = table.Column(type: "char(36)", nullable: false), CurriculumPlanId = table.Column(type: "char(36)", nullable: true), StudentStatusSnapshot = table.Column(type: "int", nullable: false), RequiredCredits = table.Column(type: "decimal(6,2)", precision: 6, scale: 2, nullable: false), EarnedCredits = table.Column(type: "decimal(6,2)", precision: 6, scale: 2, nullable: false), RequiredCourseCount = table.Column(type: "int", nullable: false), PassedRequiredCourseCount = table.Column(type: "int", nullable: false), FailedCourseCount = table.Column(type: "int", nullable: false), MissingCourseNames = table.Column(type: "varchar(2000)", maxLength: 2000, nullable: false), CalculatedConclusion = table.Column(type: "int", nullable: false), Conclusion = table.Column(type: "int", nullable: false), IsOverridden = table.Column(type: "tinyint(1)", nullable: false), ReviewComment = table.Column(type: "varchar(500)", maxLength: 500, nullable: true), ReviewedAt = 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_GraduationAuditResults", x => x.Id); table.ForeignKey( name: "FK_GraduationAuditResults_CurriculumPlans_CurriculumPlanId", column: x => x.CurriculumPlanId, principalTable: "CurriculumPlans", principalColumn: "Id", onDelete: ReferentialAction.SetNull); table.ForeignKey( name: "FK_GraduationAuditResults_GraduationAuditBatches_GraduationAudi~", column: x => x.GraduationAuditBatchId, principalTable: "GraduationAuditBatches", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_GraduationAuditResults_Students_StudentId", column: x => x.StudentId, principalTable: "Students", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }) .Annotation("MySQL:Charset", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_GraduationAuditBatches_GraduationYear_EnrollmentYear", table: "GraduationAuditBatches", columns: new[] { "GraduationYear", "EnrollmentYear" }); migrationBuilder.CreateIndex( name: "IX_GraduationAuditBatches_Status", table: "GraduationAuditBatches", column: "Status"); migrationBuilder.CreateIndex( name: "IX_GraduationAuditResults_Conclusion_IsOverridden", table: "GraduationAuditResults", columns: new[] { "Conclusion", "IsOverridden" }); migrationBuilder.CreateIndex( name: "IX_GraduationAuditResults_CurriculumPlanId", table: "GraduationAuditResults", column: "CurriculumPlanId"); migrationBuilder.CreateIndex( name: "IX_GraduationAuditResults_GraduationAuditBatchId_StudentId", table: "GraduationAuditResults", columns: new[] { "GraduationAuditBatchId", "StudentId" }, unique: true); migrationBuilder.CreateIndex( name: "IX_GraduationAuditResults_StudentId", table: "GraduationAuditResults", column: "StudentId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "GraduationAuditResults"); migrationBuilder.DropTable( name: "GraduationAuditBatches"); } } }