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

@@ -154,3 +154,12 @@ exports.getDatabase = () => ({
name: database.id,
version: last(exports.migrations).version,
});
exports.getLatestVersion = () => {
const lastMigration = last(migrations);
if (!lastMigration) {
return null;
}
return lastMigration.version;
};