[geary/mjog/934-gmail-duplicate-messages] sql: Add db migrations to clean up duplicate messages and message_ids
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/934-gmail-duplicate-messages] sql: Add db migrations to clean up duplicate messages and message_ids
- Date: Sat, 22 Aug 2020 07:33:51 +0000 (UTC)
commit b9f2d87b752e75cf319156629d04dff4229b3565
Author: Michael Gratton <mike vee net>
Date: Sat Aug 22 17:06:50 2020 +1000
sql: Add db migrations to clean up duplicate messages and message_ids
sql/version-028.sql | 6 ++++++
sql/version-029.sql | 10 ++++++++++
test/engine/imap-db/imap-db-database-test.vala | 2 +-
3 files changed, 17 insertions(+), 1 deletion(-)
---
diff --git a/sql/version-028.sql b/sql/version-028.sql
new file mode 100644
index 000000000..ff38053ef
--- /dev/null
+++ b/sql/version-028.sql
@@ -0,0 +1,6 @@
+--
+-- Rebuild corrupted message ids, again
+--
+
+UPDATE MessageTable
+SET message_id = trim(trim(message_id), '\n');
diff --git a/sql/version-029.sql b/sql/version-029.sql
new file mode 100644
index 000000000..2e823ec0b
--- /dev/null
+++ b/sql/version-029.sql
@@ -0,0 +1,10 @@
+--
+-- Drop duplicate messages. These will remove any messages with
+-- non-empty message ids that are duplicates of an earlier
+-- message. Any missing messages will be re-downloaded.
+--
+
+DELETE FROM MessageTable
+WHERE message_id != '' AND id NOT IN (
+ SELECT min(id) FROM MessageTable GROUP BY message_id
+)
diff --git a/test/engine/imap-db/imap-db-database-test.vala b/test/engine/imap-db/imap-db-database-test.vala
index 29d387687..7388afa5d 100644
--- a/test/engine/imap-db/imap-db-database-test.vala
+++ b/test/engine/imap-db/imap-db-database-test.vala
@@ -107,7 +107,7 @@ class Geary.ImapDB.DatabaseTest : TestCase {
);
db.open.end(async_result());
- assert_equal<int?>(db.get_schema_version(), 27, "Post-upgrade version");
+ assert_equal<int?>(db.get_schema_version(), 29, "Post-upgrade version");
// Since schema v22 deletes the re-creates all attachments,
// attachment 12 should no longer exist on the file system and
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]