using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Jiaowu.Api.Infrastructure.Persistence.Migrations.MySql; public partial class AllowAllScheduledExperimentLessons : Migration { protected override void Up(MigrationBuilder migrationBuilder) { // MySQL 可能将旧唯一索引用于外键支撑。先提供同列的普通索引, // 再替换业务唯一索引,避免线上迁移因外键依赖而中断。 migrationBuilder.CreateIndex( name: "IX_ExperimentProjects_TeachingTaskId_Code_FkSupport", table: "ExperimentProjects", columns: new[] { "TeachingTaskId", "Code" }); migrationBuilder.DropIndex( name: "IX_ExperimentProjects_TeachingTaskId_Code", table: "ExperimentProjects"); migrationBuilder.CreateIndex( name: "IX_ExperimentProjects_TeachingTaskId_Code_ScheduleEntryId", table: "ExperimentProjects", columns: new[] { "TeachingTaskId", "Code", "ScheduleEntryId" }, unique: true); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropIndex( name: "IX_ExperimentProjects_TeachingTaskId_Code_ScheduleEntryId", table: "ExperimentProjects"); migrationBuilder.CreateIndex( name: "IX_ExperimentProjects_TeachingTaskId_Code", table: "ExperimentProjects", columns: new[] { "TeachingTaskId", "Code" }, unique: true); migrationBuilder.DropIndex( name: "IX_ExperimentProjects_TeachingTaskId_Code_FkSupport", table: "ExperimentProjects"); } }