Conditionally run post-attachment migrations

Introduce placeholder migrations for Backbone models so they never implicitly
run migrations whenever they are `fetch`ed. We prefer to run our migrations
explicitly upon app startup and then let Backbone models be (slightly) dumb(er)
models, without inadvertently triggering migrations.
This commit is contained in:
Daniel Gasienica 2018-03-30 16:31:33 -04:00
parent 887bd83852
commit 805031ade8
6 changed files with 87 additions and 25 deletions

View file

@ -83,23 +83,15 @@
const cancelInitializationMessage = Views.Initialization.setMessage();
console.log('Start IndexedDB migrations');
console.log('Migrate database with attachments');
console.log('Run migrations on database with attachment data');
await Migrations0DatabaseWithAttachmentData.run({ Backbone });
// console.log('Migrate attachments to disk');
// const database = Migrations0DatabaseWithAttachmentData.getDatabase();
// await MessageDataMigrator.processAll({
// Backbone,
// databaseName: database.name,
// minDatabaseVersion: database.version,
// upgradeMessageSchema,
// });
// console.log('Migrate database without attachments');
// await Migrations1DatabaseWithoutAttachmentData.run({
// Backbone,
// database: Whisper.Database,
// });
const database = Whisper.Database;
const status = await Migrations1DatabaseWithoutAttachmentData.getStatus({ database });
console.log('Run migrations on database without attachment data:', status);
if (status.canRun) {
await Migrations1DatabaseWithoutAttachmentData.run({ Backbone, database });
}
console.log('Storage fetch');
storage.fetch();