From f3703fdf3c7112ee9124c230be12767d1d2e631d Mon Sep 17 00:00:00 2001 From: biss Date: Tue, 11 Aug 2026 17:58:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dsqlite=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Persistence/DevelopmentSqliteMigrator.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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); }