fix: remove unused crypto unit fields

This commit is contained in:
Sérgio Salgado 2022-07-27 19:36:59 +01:00
parent 3b01820242
commit 65b8491354
4 changed files with 38 additions and 11 deletions

View file

@ -0,0 +1,22 @@
const { removeFromConfig, loadLatest } = require('../lib/new-settings-loader')
const { getCryptosFromWalletNamespace } = require('../lib/new-config-manager.js')
const _ = require('lodash/fp')
exports.up = function (next) {
loadLatest()
.then(settings => {
const configuredCryptos = getCryptosFromWalletNamespace(settings.config)
if (!configuredCryptos.length) return Promise.resolve()
return removeFromConfig(_.map(it => `wallets_${it}_cryptoUnits`, configuredCryptos))
})
.then(() => next())
.catch(err => {
console.log(err.message)
return next(err)
})
}
exports.down = function (next) {
next()
}