From 45dba15376ac51f59f28920171e2dbd5882aa35a Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 25 Nov 2018 20:47:50 +0100 Subject: [PATCH] one time migration for existing quicksy account to set magic create flag --- .../conversations/persistance/DatabaseBackend.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java index d5c9153b7..072e706ee 100644 --- a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java @@ -50,6 +50,7 @@ import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.entities.PresenceTemplate; import eu.siacs.conversations.entities.Roster; import eu.siacs.conversations.entities.ServiceDiscoveryResult; +import eu.siacs.conversations.services.QuickConversationsService; import eu.siacs.conversations.services.ShortcutService; import eu.siacs.conversations.utils.CryptoHelper; import eu.siacs.conversations.utils.FtsUtils; @@ -62,7 +63,7 @@ import rocks.xmpp.addr.Jid; public class DatabaseBackend extends SQLiteOpenHelper { private static final String DATABASE_NAME = "history"; - private static final int DATABASE_VERSION = 42; + private static final int DATABASE_VERSION = 43; private static DatabaseBackend instance = null; private static String CREATE_CONTATCS_STATEMENT = "create table " + Contact.TABLENAME + "(" + Contact.ACCOUNT + " TEXT, " @@ -518,6 +519,14 @@ public class DatabaseBackend extends SQLiteOpenHelper { if (oldVersion < 42 && newVersion >= 42) { db.execSQL("DROP TRIGGER IF EXISTS after_message_delete"); } + if (QuickConversationsService.isQuicksy() && oldVersion < 43 && newVersion >= 43) { + List accounts = getAccounts(db); + for (Account account : accounts) { + account.setOption(Account.OPTION_MAGIC_CREATE, true); + db.update(Account.TABLENAME, account.getContentValues(), Account.UUID + + "=?", new String[]{account.getUuid()}); + } + } } private void canonicalizeJids(SQLiteDatabase db) {