diff --git a/src/Jiaowu.Api/Infrastructure/Persistence/DevelopmentSqliteMigrator.cs b/src/Jiaowu.Api/Infrastructure/Persistence/DevelopmentSqliteMigrator.cs index 6f74098..f955808 100644 --- a/src/Jiaowu.Api/Infrastructure/Persistence/DevelopmentSqliteMigrator.cs +++ b/src/Jiaowu.Api/Infrastructure/Persistence/DevelopmentSqliteMigrator.cs @@ -739,9 +739,24 @@ public sealed class DevelopmentSqliteMigrator( NotificationInboxIndexesMigration, NotificationInboxIndexesStatements, cancellationToken); + var experimentProjectColumns = (await db.Database.SqlQueryRaw( + "SELECT name AS \"Value\" FROM pragma_table_info('ExperimentProjects')") + .ToListAsync(cancellationToken)) + .ToHashSet(StringComparer.OrdinalIgnoreCase); + var experimentSessionInstructorsExist = await db.Database + .SqlQueryRaw( + "SELECT COUNT(*) AS \"Value\" FROM sqlite_master WHERE type = 'table' AND name = 'ExperimentSessionInstructors'") + .AnyAsync(value => value > 0, cancellationToken); + var selfScheduledExperimentSelectionStatements = new List(); + if (!experimentProjectColumns.Contains("SelectionStartsAt")) + selfScheduledExperimentSelectionStatements.Add(SelfScheduledExperimentSelectionStatements[0]); + if (!experimentProjectColumns.Contains("SelectionEndsAt")) + selfScheduledExperimentSelectionStatements.Add(SelfScheduledExperimentSelectionStatements[1]); + if (!experimentSessionInstructorsExist) + selfScheduledExperimentSelectionStatements.AddRange(SelfScheduledExperimentSelectionStatements.Skip(2)); await ApplyMigrationAsync( SelfScheduledExperimentSelectionMigration, - SelfScheduledExperimentSelectionStatements, + selfScheduledExperimentSelectionStatements, cancellationToken); }