实验排课再次修正
This commit is contained in:
@@ -94,6 +94,8 @@ public sealed class DevelopmentSqliteMigrator(
|
||||
"20260809_49_swagger_documentation_setting";
|
||||
private const string ExperimentClassroomConstraintsMigration =
|
||||
"20260809_50_experiment_classroom_constraints";
|
||||
private const string SeparateExperimentClassroomScopeMigration =
|
||||
"20260809_51_separate_experiment_classroom_scope";
|
||||
|
||||
public async Task MigrateAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
@@ -689,6 +691,16 @@ public sealed class DevelopmentSqliteMigrator(
|
||||
ExperimentClassroomConstraintsMigration,
|
||||
experimentClassroomConstraintsExist ? [] : ExperimentClassroomConstraintStatements,
|
||||
cancellationToken);
|
||||
var experimentScopeColumns = (await db.Database.SqlQueryRaw<string>(
|
||||
"SELECT name AS \"Value\" FROM pragma_table_info('TeachingTaskScheduleConstraints')")
|
||||
.ToListAsync(cancellationToken))
|
||||
.ToHashSet(StringComparer.OrdinalIgnoreCase);
|
||||
await ApplyMigrationAsync(
|
||||
SeparateExperimentClassroomScopeMigration,
|
||||
experimentScopeColumns.Contains("ExperimentRequiredCampusId")
|
||||
? []
|
||||
: SeparateExperimentClassroomScopeStatements,
|
||||
cancellationToken);
|
||||
}
|
||||
|
||||
private async Task ApplyMigrationAsync(
|
||||
@@ -2971,4 +2983,24 @@ public sealed class DevelopmentSqliteMigrator(
|
||||
ON "TeachingTaskAllowedExperimentClassrooms" ("ClassroomId");
|
||||
"""
|
||||
];
|
||||
|
||||
private static readonly string[] SeparateExperimentClassroomScopeStatements =
|
||||
[
|
||||
"""
|
||||
ALTER TABLE "TeachingTaskScheduleConstraints"
|
||||
ADD COLUMN "ExperimentRequiredCampusId" TEXT NULL;
|
||||
""",
|
||||
"""
|
||||
ALTER TABLE "TeachingTaskScheduleConstraints"
|
||||
ADD COLUMN "ExperimentRequiredBuildingId" TEXT NULL;
|
||||
""",
|
||||
"""
|
||||
CREATE INDEX "IX_TeachingTaskScheduleConstraints_ExperimentRequiredCampusId"
|
||||
ON "TeachingTaskScheduleConstraints" ("ExperimentRequiredCampusId");
|
||||
""",
|
||||
"""
|
||||
CREATE INDEX "IX_TeachingTaskScheduleConstraints_ExperimentRequiredBuildingId"
|
||||
ON "TeachingTaskScheduleConstraints" ("ExperimentRequiredBuildingId");
|
||||
"""
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user