using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql { /// public partial class CourseGradeStatistics : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "CourseGradeStatistics", columns: table => new { Id = table.Column(type: "char(36)", nullable: false), CourseId = table.Column(type: "char(36)", nullable: false), AcademicTermId = table.Column(type: "char(36)", nullable: false), Scope = table.Column(type: "int", nullable: false), ScopeEntityId = table.Column(type: "char(36)", nullable: true), StudentCount = table.Column(type: "int", nullable: false), PassedCount = table.Column(type: "int", nullable: false), Below60Count = table.Column(type: "int", nullable: false), From60To69Count = table.Column(type: "int", nullable: false), From70To79Count = table.Column(type: "int", nullable: false), From80To89Count = table.Column(type: "int", nullable: false), From90To100Count = table.Column(type: "int", nullable: false), HighestScore = table.Column(type: "decimal(5,1)", precision: 5, scale: 1, nullable: false), AverageScore = table.Column(type: "decimal(5,1)", precision: 5, scale: 1, nullable: false), LowestScore = table.Column(type: "decimal(5,1)", precision: 5, scale: 1, nullable: false), PassRate = table.Column(type: "decimal(5,2)", precision: 5, scale: 2, nullable: false), CalculatedAt = table.Column(type: "datetime(6)", nullable: false), CreatedAt = table.Column(type: "datetime(6)", nullable: false), UpdatedAt = table.Column(type: "datetime(6)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_CourseGradeStatistics", x => x.Id); table.ForeignKey( name: "FK_CourseGradeStatistics_AcademicTerms_AcademicTermId", column: x => x.AcademicTermId, principalTable: "AcademicTerms", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_CourseGradeStatistics_Courses_CourseId", column: x => x.CourseId, principalTable: "Courses", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }) .Annotation("MySQL:Charset", "utf8mb4"); migrationBuilder.CreateTable( name: "CourseGradeStatisticsRefreshJobs", columns: table => new { Id = table.Column(type: "char(36)", nullable: false), GradeSheetId = table.Column(type: "char(36)", nullable: false), Status = table.Column(type: "int", nullable: false), StartedAt = table.Column(type: "datetime(6)", nullable: true), CompletedAt = table.Column(type: "datetime(6)", nullable: true), ErrorMessage = table.Column(type: "varchar(2000)", maxLength: 2000, nullable: true), CreatedAt = table.Column(type: "datetime(6)", nullable: false), UpdatedAt = table.Column(type: "datetime(6)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_CourseGradeStatisticsRefreshJobs", x => x.Id); table.ForeignKey( name: "FK_CourseGradeStatisticsRefreshJobs_GradeSheets_GradeSheetId", column: x => x.GradeSheetId, principalTable: "GradeSheets", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySQL:Charset", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_CourseGradeStatistics_AcademicTermId_Scope_ScopeEntityId", table: "CourseGradeStatistics", columns: new[] { "AcademicTermId", "Scope", "ScopeEntityId" }); migrationBuilder.CreateIndex( name: "UX_CourseGradeStatistics_Scope", table: "CourseGradeStatistics", columns: new[] { "CourseId", "AcademicTermId", "Scope", "ScopeEntityId" }, unique: true); migrationBuilder.CreateIndex( name: "IX_CourseGradeStatisticsRefreshJobs_GradeSheetId", table: "CourseGradeStatisticsRefreshJobs", column: "GradeSheetId"); migrationBuilder.CreateIndex( name: "IX_CourseGradeStatisticsRefreshJobs_Status_CreatedAt", table: "CourseGradeStatisticsRefreshJobs", columns: new[] { "Status", "CreatedAt" }); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "CourseGradeStatistics"); migrationBuilder.DropTable( name: "CourseGradeStatisticsRefreshJobs"); } } }