Fix attachment migration error when database contains attachments for deleted messages

Closes #264
This commit is contained in:
chylex 2024-08-04 21:43:43 +02:00
parent d3e1bb901c
commit 9f1db9a662
No known key found for this signature in database
GPG Key ID: 4DE42C8F19A80548

View File

@ -9,7 +9,7 @@ sealed class SqliteSchemaUpgradeTo9 : ISchemaUpgrade {
await SqliteSchema.CreateMessageAttachmentsTable(conn);
await reporter.MainWork("Migrating message attachments...", 1, 3);
await conn.ExecuteAsync("INSERT INTO message_attachments (message_id, attachment_id) SELECT message_id, attachment_id FROM attachments");
await conn.ExecuteAsync("INSERT INTO message_attachments (message_id, attachment_id) SELECT message_id, attachment_id FROM attachments a JOIN messages m USING (message_id)");
await reporter.MainWork("Applying schema changes...", 2, 3);
await conn.ExecuteAsync("DROP INDEX attachments_message_ix");