Queue chat bulk actions through SQL outbox
This commit is contained in:
@@ -157,6 +157,41 @@ static async Task EnsureCompatibilitySchemaAsync(QMaxDbContext db)
|
||||
await db.Database.ExecuteSqlRawAsync("ALTER TABLE Chats ADD COLUMN WebUrl TEXT;");
|
||||
}
|
||||
|
||||
if (!chatColumns.Contains("DeletedAt"))
|
||||
{
|
||||
await db.Database.ExecuteSqlRawAsync("ALTER TABLE Chats ADD COLUMN DeletedAt TEXT;");
|
||||
}
|
||||
|
||||
if (!chatColumns.Contains("HistoryClearedAt"))
|
||||
{
|
||||
await db.Database.ExecuteSqlRawAsync("ALTER TABLE Chats ADD COLUMN HistoryClearedAt TEXT;");
|
||||
}
|
||||
|
||||
if (!chatColumns.Contains("PendingMaxAction"))
|
||||
{
|
||||
await db.Database.ExecuteSqlRawAsync("ALTER TABLE Chats ADD COLUMN PendingMaxAction TEXT;");
|
||||
}
|
||||
|
||||
if (!chatColumns.Contains("PendingMaxActionRequestedAt"))
|
||||
{
|
||||
await db.Database.ExecuteSqlRawAsync("ALTER TABLE Chats ADD COLUMN PendingMaxActionRequestedAt TEXT;");
|
||||
}
|
||||
|
||||
if (!chatColumns.Contains("PendingMaxActionLastAttemptAt"))
|
||||
{
|
||||
await db.Database.ExecuteSqlRawAsync("ALTER TABLE Chats ADD COLUMN PendingMaxActionLastAttemptAt TEXT;");
|
||||
}
|
||||
|
||||
if (!chatColumns.Contains("PendingMaxActionAttempts"))
|
||||
{
|
||||
await db.Database.ExecuteSqlRawAsync("ALTER TABLE Chats ADD COLUMN PendingMaxActionAttempts INTEGER NOT NULL DEFAULT 0;");
|
||||
}
|
||||
|
||||
if (!chatColumns.Contains("PendingMaxActionError"))
|
||||
{
|
||||
await db.Database.ExecuteSqlRawAsync("ALTER TABLE Chats ADD COLUMN PendingMaxActionError TEXT;");
|
||||
}
|
||||
|
||||
var attachmentColumns = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
await using (var command = connection.CreateCommand())
|
||||
{
|
||||
@@ -189,6 +224,16 @@ static async Task EnsureCompatibilitySchemaAsync(QMaxDbContext db)
|
||||
WHERE ExternalId IS NOT NULL AND ExternalId <> '';
|
||||
""");
|
||||
|
||||
await db.Database.ExecuteSqlRawAsync("""
|
||||
CREATE INDEX IF NOT EXISTS IX_Chats_DeletedAt
|
||||
ON Chats (DeletedAt);
|
||||
""");
|
||||
|
||||
await db.Database.ExecuteSqlRawAsync("""
|
||||
CREATE INDEX IF NOT EXISTS IX_Chats_PendingMaxAction_PendingMaxActionRequestedAt
|
||||
ON Chats (PendingMaxAction, PendingMaxActionRequestedAt);
|
||||
""");
|
||||
|
||||
await db.Database.ExecuteSqlRawAsync("""
|
||||
CREATE INDEX IF NOT EXISTS IX_Messages_ChatId_ExternalId
|
||||
ON Messages (ChatId, ExternalId);
|
||||
|
||||
Reference in New Issue
Block a user