chore: deprecate old migrations
This commit is contained in:
parent
f5ba3dbf4e
commit
ca68fdd0a2
13 changed files with 15 additions and 2293 deletions
|
|
@ -1,34 +1,9 @@
|
|||
const db = require('./db')
|
||||
const machineLoader = require('../lib/machine-loader')
|
||||
const { migrationSaveConfig, saveAccounts, loadLatest } = require('../lib/new-settings-loader')
|
||||
const { migrate } = require('../lib/config-migration')
|
||||
|
||||
const _ = require('lodash/fp')
|
||||
|
||||
const OLD_SETTINGS_LOADER_SCHEMA_VERSION = 1
|
||||
|
||||
// This migration was actually a config update
|
||||
// it's from before 7.5 and we update one major version at a time
|
||||
// v10.2 is good enough to deprecate it
|
||||
// file still has to exist so that the migration tool doesn't throw an error
|
||||
module.exports.up = function (next) {
|
||||
function migrateConfig (settings) {
|
||||
const newSettings = migrate(settings.config, settings.accounts)
|
||||
return Promise.all([
|
||||
migrationSaveConfig(newSettings.config),
|
||||
saveAccounts(newSettings.accounts)
|
||||
])
|
||||
.then(() => next())
|
||||
}
|
||||
|
||||
loadLatest(OLD_SETTINGS_LOADER_SCHEMA_VERSION)
|
||||
.then(settings => _.isEmpty(settings.config)
|
||||
? next()
|
||||
: migrateConfig(settings)
|
||||
)
|
||||
.catch(err => {
|
||||
if (err.message === 'lamassu-server is not configured') {
|
||||
return next()
|
||||
}
|
||||
console.log(err.message)
|
||||
return next(err)
|
||||
})
|
||||
next()
|
||||
}
|
||||
|
||||
module.exports.down = function (next) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue