diff --git a/packages/server/migrations/1750000000000-add-lnbits-config.js b/packages/server/migrations/1750000000000-add-lnbits-config.js index 35900fad..351f0b13 100644 --- a/packages/server/migrations/1750000000000-add-lnbits-config.js +++ b/packages/server/migrations/1750000000000-add-lnbits-config.js @@ -1,34 +1,17 @@ -const db = require('./db') +const { saveConfig } = require('../lib/new-settings-loader') exports.up = function (next) { - const sql = [ - `INSERT INTO user_config (name, display_name, type, data_type, config_type, enabled, secret, options) - VALUES - ('lnbitsEndpoint', 'LNBits Server URL', 'text', 'string', 'wallets', false, false, null), - ('lnbitsAdminKey', 'LNBits Admin Key', 'text', 'string', 'wallets', false, true, null) - ON CONFLICT (name) DO NOTHING`, - - `INSERT INTO user_config (name, display_name, type, data_type, config_type, enabled, secret, options) - VALUES - ('LN_wallet', 'Lightning Network Wallet', 'text', 'string', 'wallets', true, false, - '[{"code": "lnbits", "display": "LNBits"}, {"code": "galoy", "display": "Galoy (Blink)"}, {"code": "bitcoind", "display": "Bitcoin Core"}]') - ON CONFLICT (name) - DO UPDATE SET options = EXCLUDED.options - WHERE user_config.options NOT LIKE '%lnbits%'` - ] + const config = { + 'lnbits_endpoint': '', + 'lnbits_adminKey': '', + 'LN_wallet': 'lnbits' + } - db.multi(sql, next) + saveConfig(config).then(next).catch(next) } exports.down = function (next) { - const sql = [ - `DELETE FROM user_config - WHERE name IN ('lnbitsEndpoint', 'lnbitsAdminKey')`, - - `UPDATE user_config - SET options = REPLACE(options, ', {"code": "lnbits", "display": "LNBits"}', '') - WHERE name = 'LN_wallet'` - ] - - db.multi(sql, next) + // No-op - removing config entries is not typically done in down migrations + // as it could break existing configurations + next() } \ No newline at end of file