fix: save config used on migration
This commit is contained in:
parent
c072803ac3
commit
bd2d2b06c2
12 changed files with 31 additions and 19 deletions
|
|
@ -82,6 +82,17 @@ function saveConfig (config) {
|
|||
})
|
||||
}
|
||||
|
||||
function migrationSaveConfig (config) {
|
||||
return loadLatestConfigOrNone()
|
||||
.then(currentConfig => {
|
||||
const newConfig = _.assign(currentConfig, config)
|
||||
return db.tx(t => {
|
||||
return t.none(configSql, ['config', { config: newConfig }, true, NEW_SETTINGS_LOADER_SCHEMA_VERSION])
|
||||
.then(() => t.none('NOTIFY $1:name, $2', ['poller', JSON.stringify({ type: 'reload', schema: asyncLocalStorage.getStore().get('schema') })]))
|
||||
}).catch(console.error)
|
||||
})
|
||||
}
|
||||
|
||||
function resetConfig (schemaVersion) {
|
||||
return db.none(
|
||||
configSql,
|
||||
|
|
@ -172,6 +183,7 @@ function migrate () {
|
|||
|
||||
module.exports = {
|
||||
saveConfig,
|
||||
migrationSaveConfig,
|
||||
resetConfig,
|
||||
saveAccounts,
|
||||
resetAccounts,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
const db = require('./db')
|
||||
const machineLoader = require('../lib/machine-loader')
|
||||
const { saveConfig, saveAccounts, loadLatest } = require('../lib/new-settings-loader')
|
||||
const { migrationSaveConfig, saveAccounts, loadLatest } = require('../lib/new-settings-loader')
|
||||
const { migrate } = require('../lib/config-migration')
|
||||
|
||||
const _ = require('lodash/fp')
|
||||
|
|
@ -11,7 +11,7 @@ module.exports.up = function (next) {
|
|||
function migrateConfig (settings) {
|
||||
const newSettings = migrate(settings.config, settings.accounts)
|
||||
return Promise.all([
|
||||
saveConfig(newSettings.config),
|
||||
migrationSaveConfig(newSettings.config),
|
||||
saveAccounts(newSettings.accounts)
|
||||
])
|
||||
.then(() => next())
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ exports.up = function (next) {
|
|||
}
|
||||
})(deviceIds)
|
||||
|
||||
return settingsLoader.saveConfig(config)
|
||||
return settingsLoader.migrationSaveConfig(config)
|
||||
})
|
||||
.then(() => next())
|
||||
.catch(err => next(err))
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
const { saveConfig } = require('../lib/new-settings-loader')
|
||||
const { migrationSaveConfig } = require('../lib/new-settings-loader')
|
||||
|
||||
exports.up = function (next) {
|
||||
const triggersDefault = {
|
||||
|
|
@ -6,7 +6,7 @@ exports.up = function (next) {
|
|||
triggersConfig_automation: 'Automatic'
|
||||
}
|
||||
|
||||
return saveConfig(triggersDefault)
|
||||
return migrationSaveConfig(triggersDefault)
|
||||
.then(() => next())
|
||||
.catch(err => {
|
||||
console.log(err.message)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ exports.up = async function (next) {
|
|||
config[key] = 'none'
|
||||
}
|
||||
}, cryptoCodes)
|
||||
return settingsLoader.saveConfig(config)
|
||||
return settingsLoader.migrationSaveConfig(config)
|
||||
}
|
||||
|
||||
exports.down = function (next) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const _ = require('lodash/fp')
|
||||
const { saveConfig, loadLatest } = require('../lib/new-settings-loader')
|
||||
const { migrationSaveConfig, loadLatest } = require('../lib/new-settings-loader')
|
||||
const { CASSETTE_MAX_CAPACITY } = require('../lib/constants')
|
||||
|
||||
exports.up = function (next) {
|
||||
|
|
@ -49,7 +49,7 @@ exports.up = function (next) {
|
|||
return newOverride
|
||||
}, config.notifications_fiatBalanceOverrides)
|
||||
}
|
||||
return saveConfig(newConfig)
|
||||
return migrationSaveConfig(newConfig)
|
||||
.then(() => next())
|
||||
})
|
||||
.catch(err => {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ exports.up = function (next) {
|
|||
.then(({ config }) => {
|
||||
if (!_.isEmpty(config))
|
||||
config.locale_timezone = '0:0'
|
||||
return settingsLoader.saveConfig(config)
|
||||
return settingsLoader.migrationSaveConfig(config)
|
||||
})
|
||||
.then(() => next())
|
||||
.catch(err => next(err))
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
const { saveConfig, loadLatest } = require('../lib/new-settings-loader')
|
||||
const { migrationSaveConfig, loadLatest } = require('../lib/new-settings-loader')
|
||||
|
||||
exports.up = function (next) {
|
||||
const newConfig = {
|
||||
|
|
@ -6,7 +6,7 @@ exports.up = function (next) {
|
|||
}
|
||||
return loadLatest()
|
||||
.then(config => {
|
||||
return saveConfig(newConfig)
|
||||
return migrationSaveConfig(newConfig)
|
||||
.then(() => next())
|
||||
.catch(err => {
|
||||
if (err.message === 'lamassu-server is not configured') {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const _ = require('lodash/fp')
|
||||
const { saveConfig, loadLatest } = require('../lib/new-settings-loader')
|
||||
const { migrationSaveConfig, loadLatest } = require('../lib/new-settings-loader')
|
||||
const { getCryptosFromWalletNamespace } = require('../lib/new-config-manager')
|
||||
|
||||
exports.up = function (next) {
|
||||
|
|
@ -8,7 +8,7 @@ exports.up = function (next) {
|
|||
.then(config => {
|
||||
const coins = getCryptosFromWalletNamespace(config)
|
||||
_.map(coin => { newConfig[`wallets_${coin}_feeMultiplier`] = '1' }, coins)
|
||||
return saveConfig(newConfig)
|
||||
return migrationSaveConfig(newConfig)
|
||||
})
|
||||
.then(next)
|
||||
.catch(err => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const db = require('./db')
|
||||
const { saveConfig, loadLatest } = require('../lib/new-settings-loader')
|
||||
const { migrationSaveConfig, loadLatest } = require('../lib/new-settings-loader')
|
||||
|
||||
exports.up = function (next) {
|
||||
const sql = [
|
||||
|
|
@ -19,7 +19,7 @@ exports.up = function (next) {
|
|||
newConfig.notifications_notificationCenter_security = true
|
||||
}
|
||||
|
||||
return saveConfig(newConfig)
|
||||
return migrationSaveConfig(newConfig)
|
||||
.then(() => db.multi(sql, next))
|
||||
.catch(err => {
|
||||
return next(err)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
const { saveConfig, loadLatest } = require('../lib/new-settings-loader')
|
||||
const { migrationSaveConfig, loadLatest } = require('../lib/new-settings-loader')
|
||||
const { getCryptosFromWalletNamespace } = require('../lib/new-config-manager.js')
|
||||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
const _ = require('lodash/fp')
|
||||
|
|
@ -14,7 +14,7 @@ exports.up = function (next) {
|
|||
newSettings[`wallets_${crypto}_cryptoUnits`] = defaultUnit
|
||||
return newSettings
|
||||
}, activeCryptos)
|
||||
return saveConfig(newSettings)
|
||||
return migrationSaveConfig(newSettings)
|
||||
})
|
||||
.then(() => next())
|
||||
.catch(err => {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
var db = require('./db')
|
||||
const _ = require('lodash/fp')
|
||||
const { saveConfig, loadLatest } = require('../lib/new-settings-loader')
|
||||
const { migrationSaveConfig, loadLatest } = require('../lib/new-settings-loader')
|
||||
const { getMachines } = require('../lib/machine-loader')
|
||||
|
||||
exports.up = function (next) {
|
||||
|
|
@ -40,7 +40,7 @@ exports.up = function (next) {
|
|||
return acc
|
||||
}, {}, formattedMachines)
|
||||
|
||||
return saveConfig(newConfig)
|
||||
return migrationSaveConfig(newConfig)
|
||||
.then(() => db.multi(sql, next))
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue