lamassu-server/migrations/1658940716689-remove-coin-specific-cryptounits.js

22 lines
656 B
JavaScript

const { removeFromConfig, loadLatestConfig } = require('../lib/new-settings-loader')
const { getCryptosFromWalletNamespace } = require('../lib/new-config-manager.js')
const _ = require('lodash/fp')
exports.up = function (next) {
loadLatestConfig()
.then(config => {
const configuredCryptos = getCryptosFromWalletNamespace(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()
}