Fix: delete old zeroConfLimit config data after migrating

This commit is contained in:
csrapr 2021-04-08 19:25:32 +01:00 committed by Josh Harvey
parent ac38a40b6c
commit fafee1a727

View file

@ -10,6 +10,7 @@ exports.up = function (next) {
const mp = t.any('SELECT device_id FROM devices') const mp = t.any('SELECT device_id FROM devices')
const [{ config }, machines] = await Promise.all([sp, mp]) const [{ config }, machines] = await Promise.all([sp, mp])
const cryptoCurrencies = config.locale_cryptoCurrencies const cryptoCurrencies = config.locale_cryptoCurrencies
_.forEach(o => { _.forEach(o => {
const machineId = o.device_id const machineId = o.device_id
const cashOutConfig = configManager.getCashOut(machineId, config) const cashOutConfig = configManager.getCashOut(machineId, config)
@ -29,6 +30,14 @@ exports.up = function (next) {
config[key] = Number(min) config[key] = Number(min)
} }
}, cryptoCurrencies) }, cryptoCurrencies)
const regexp = /^cashOut_[0-9a-z]+_zeroConfLimit$/
const keysToErase = Object.keys(config).filter(key => key.match(regexp))
_.forEach(key => {
config[key] = null
}, keysToErase)
return settingsLoader.saveConfig(config) return settingsLoader.saveConfig(config)
}) })
.then(() => next()) .then(() => next())