[geary/mjog/message-id-db: 2/2] sql: Add migration for bad message-id data in the database




commit 33801f22efd445cdfc8a8bd109a01dce3a8e9579
Author: Michael Gratton <mike vee net>
Date:   Thu Aug 13 15:50:07 2020 +1000

    sql: Add migration for bad message-id data in the database

 sql/version-027.sql                            | 7 +++++++
 test/engine/imap-db/imap-db-database-test.vala | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/sql/version-027.sql b/sql/version-027.sql
new file mode 100644
index 000000000..f09f24f04
--- /dev/null
+++ b/sql/version-027.sql
@@ -0,0 +1,7 @@
+--
+-- Rebuild corrupted message ids.
+--
+
+UPDATE MessageTable
+SET message_id = '<' || message_id || '>'
+WHERE (message_id NOT LIKE '<%') AND (message_id NOT LIKE ' <%');
diff --git a/test/engine/imap-db/imap-db-database-test.vala b/test/engine/imap-db/imap-db-database-test.vala
index 1f03d4a9f..29d387687 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(), 26, "Post-upgrade version");
+        assert_equal<int?>(db.get_schema_version(), 27, "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]