fix: check for empty user config before migrate
This commit is contained in:
parent
5fe02e765d
commit
f45ba41b14
1 changed files with 17 additions and 4 deletions
|
|
@ -3,6 +3,8 @@ const machineLoader = require('../lib/machine-loader')
|
|||
const { saveConfig, saveAccounts, loadLatest } = require('../lib/new-settings-loader')
|
||||
const { migrate } = require('../lib/config-migration')
|
||||
|
||||
const _ = require('lodash/fp')
|
||||
|
||||
const OLD_SETTINGS_LOADER_SCHEMA_VERSION = 1
|
||||
|
||||
module.exports.up = function (next) {
|
||||
|
|
@ -16,11 +18,22 @@ module.exports.up = function (next) {
|
|||
}
|
||||
|
||||
loadLatest(OLD_SETTINGS_LOADER_SCHEMA_VERSION)
|
||||
.then(async settings => ({
|
||||
settings,
|
||||
machines: await machineLoader.getMachineNames(settings.config)
|
||||
}))
|
||||
.then(async settings => {
|
||||
if (_.isEmpty(settings.config)) {
|
||||
return {
|
||||
settings,
|
||||
machines: []
|
||||
}
|
||||
}
|
||||
return {
|
||||
settings,
|
||||
machines: await machineLoader.getMachineNames(settings.config)
|
||||
}
|
||||
})
|
||||
.then(({ settings, machines }) => {
|
||||
if (_.isEmpty(settings.config)) {
|
||||
return next()
|
||||
}
|
||||
const sql = machines
|
||||
? machines.map(m => `update devices set name = '${m.name}' where device_id = '${m.deviceId}'`)
|
||||
: []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue