fix: don't update machine names from queried machine names

This commit is contained in:
André Sá 2021-11-30 20:14:03 +00:00
parent 77f99ea8e8
commit fad165f55f

View file

@ -18,27 +18,10 @@ module.exports.up = function (next) {
} }
loadLatest(OLD_SETTINGS_LOADER_SCHEMA_VERSION) loadLatest(OLD_SETTINGS_LOADER_SCHEMA_VERSION)
.then(async settings => { .then(settings => _.isEmpty(settings.config)
if (_.isEmpty(settings.config)) { ? next()
return { : migrateConfig(settings)
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}'`)
: []
return db.multi(sql, () => migrateConfig(settings))
})
.catch(err => { .catch(err => {
if (err.message === 'lamassu-server is not configured') { if (err.message === 'lamassu-server is not configured') {
return next() return next()