From 7532f397ea2a800231cb481a99491061448dfaca Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Mon, 15 Oct 2018 12:24:43 -0700 Subject: [PATCH] Keep object stores after conversations migrate to SQLCipher --- js/background.js | 22 +------------------ ...rations_0_database_with_attachment_data.js | 11 ++++++++++ ...ions_1_database_without_attachment_data.js | 6 ++--- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/js/background.js b/js/background.js index 81cbf9de894..714af3f243b 100644 --- a/js/background.js +++ b/js/background.js @@ -131,10 +131,7 @@ deleteAttachmentData, getCurrentVersion, } = window.Signal.Migrations; - const { - Migrations0DatabaseWithAttachmentData, - Migrations1DatabaseWithoutAttachmentData, - } = window.Signal.Migrations; + const { Migrations0DatabaseWithAttachmentData } = window.Signal.Migrations; const { Views } = window.Signal; // Implicitly used in `indexeddb-backbonejs-adapter`: @@ -391,20 +388,6 @@ Views.Initialization.setMessage(window.i18n('optimizingApplication')); - window.log.info('Running cleanup IndexedDB migrations...'); - await Whisper.Database.close(); - - // Now we clean up IndexedDB database after extracting data from it - await Migrations1DatabaseWithoutAttachmentData.run({ - Backbone, - logger: window.log, - }); - - const latestDBVersion = _.last( - Migrations1DatabaseWithoutAttachmentData.migrations - ).version; - Whisper.Database.migrations[0].version = latestDBVersion; - window.log.info('Cleanup: starting...'); const messagesForCleanup = await window.Signal.Data.getOutgoingWithoutExpiresAt( { @@ -452,9 +435,6 @@ Views.Initialization.setMessage(window.i18n('loading')); - // Note: We are not invoking the second set of IndexedDB migrations because it is - // likely that any future migrations will simply extracting things from IndexedDB. - idleDetector = new IdleDetector(); let isMigrationWithIndexComplete = false; window.log.info( diff --git a/js/modules/migrations/migrations_0_database_with_attachment_data.js b/js/modules/migrations/migrations_0_database_with_attachment_data.js index 324d5de584c..76d70f0955b 100644 --- a/js/modules/migrations/migrations_0_database_with_attachment_data.js +++ b/js/modules/migrations/migrations_0_database_with_attachment_data.js @@ -165,6 +165,17 @@ const migrations = [ next(); }, }, + { + version: 19, + migrate(transaction, next) { + window.log.info('Migration 19'); + + // Empty because we don't want to cause incompatibility with users who have already + // run migration 19 when it was the object store removal. + + next(); + }, + }, ]; const database = { diff --git a/js/modules/migrations/migrations_1_database_without_attachment_data.js b/js/modules/migrations/migrations_1_database_without_attachment_data.js index 7b702213351..5377a67a828 100644 --- a/js/modules/migrations/migrations_1_database_without_attachment_data.js +++ b/js/modules/migrations/migrations_1_database_without_attachment_data.js @@ -6,12 +6,12 @@ const db = require('../database'); const settings = require('../settings'); const { runMigrations } = require('./run_migrations'); -// These are cleanup migrations, to be run after migration to SQLCipher +// These are migrations for after the SQLCipher migration, currently not running exports.migrations = [ { - version: 19, + version: 20, migrate(transaction, next) { - window.log.info('Migration 19'); + window.log.info('Migration 20'); window.log.info( 'Removing messages, unprocessed, and conversations object stores' );