将索引缩短为 IX_CE_Offering_Status_WaitlistedAt。

将候补迁移改为可重入:先检查列和索引是否存在,再执行 DDL。
附件中已经成功添加 WaitlistedAt、但索引创建失败的数据库可直接重试,不会报重复列。
运行时和 dotnet ef 连接统一开启 AllowUserVariables;Connector/NET 默认关闭该选项。Connector/NET 官方说明
增加所有 MySQL 索引名不得超过 64 字符的回归测试。
This commit is contained in:
biss committed 2026-07-26 16:24:52 +08:00
1 parent f62cd21319
commit ec28eb6c16
9 files changed
+148 -30

No files matched your search

@@ -518,7 +518,7 @@ public sealed class AppDbContext(DbContextOptions<AppDbContext> options)
x.CourseSelectionOfferingId,
x.Status,
x.WaitlistedAt
});
}).HasDatabaseName("IX_CE_Offering_Status_WaitlistedAt");
entity.HasOne(x => x.CourseSelectionOffering)
.WithMany(x => x.Enrollments)
.HasForeignKey(x => x.CourseSelectionOfferingId)
@@ -12,7 +12,7 @@ public sealed class AppDbContextFactory : IDesignTimeDbContextFactory<AppDbConte
?? "Server=localhost;Port=3306;Database=jiaowu;User=__design_time__;Password=__not_used__;";
var options = new DbContextOptionsBuilder<AppDbContext>()
.UseMySQL(connectionString)
.UseMySQL(MySqlConnectionStringPolicy.ForApplication(connectionString))
.Options;
return new AppDbContext(options);
@@ -1611,7 +1611,7 @@ public sealed class DevelopmentSqliteMigrator(
ADD COLUMN "WaitlistedAt" TEXT NULL;
""",
"""
CREATE INDEX IF NOT EXISTS "IX_CourseEnrollments_CourseSelectionOfferingId_Status_WaitlistedAt"
CREATE INDEX IF NOT EXISTS "IX_CE_Offering_Status_WaitlistedAt"
ON "CourseEnrollments" ("CourseSelectionOfferingId", "Status", "WaitlistedAt");
"""
];
Loaded 3 of 9 files, more files were not shown because too many files have changed in this diff. Show more