signal-desktop/js/modules/migrations/get_placeholder_migrations.js

36 lines
846 B
JavaScript
Raw Normal View History

2018-09-21 01:47:19 +00:00
/* global window, Whisper */
2018-10-18 01:01:21 +00:00
const Migrations = require('./migrations');
exports.getPlaceholderMigrations = () => {
2018-10-18 01:01:21 +00:00
const version = Migrations.getLatestVersion();
2018-04-27 21:25:04 +00:00
return [
{
2018-10-18 01:01:21 +00:00
version,
2018-04-27 21:25:04 +00:00
migrate() {
throw new Error(
'Unexpected invocation of placeholder migration!' +
'\n\nMigrations must explicitly be run upon application startup instead' +
' of implicitly via Backbone IndexedDB adapter at any time.'
);
},
},
2018-04-27 21:25:04 +00:00
];
};
2018-09-21 01:47:19 +00:00
exports.getCurrentVersion = () =>
new Promise((resolve, reject) => {
const request = window.indexedDB.open(Whisper.Database.id);
request.onerror = reject;
request.onupgradeneeded = reject;
request.onsuccess = () => {
const db = request.result;
const { version } = db;
return resolve(version);
};
});