Merge pull request #1118 from chaotixkilla/fix-sms-notices-migration

Add missing comma in SMS notices migration
This commit is contained in:
Rafael Taranto 2022-02-18 17:46:36 +00:00 committed by GitHub
commit da0843bf7f
2 changed files with 11 additions and 6 deletions

View file

@ -16,7 +16,7 @@ const getSMSNotices = () => {
}
const createSMSNotice = (event, messageName, message, enabled, allowToggle) => {
const sql = `INSERT INTO sms_notices (id, event, message_name, message${enabled ? `, enabled`: ``}${allowToggle ? `, allowToggle`: ``}) VALUES ($1, $2, $3, $4${enabled ? `, $5`: ``}${allowToggle ? `, $6`: ``})`
const sql = `INSERT INTO sms_notices (id, event, message_name, message, enabled, allow_toggle) VALUES ($1, $2, $3, $4, $5, $6)`
return db.none(sql, [uuid.v4(), _.snakeCase(event), messageName, message, enabled, allowToggle])
}

View file

@ -7,14 +7,19 @@ exports.up = function (next) {
`ALTER TYPE custom_message_event RENAME TO sms_notice_event`,
`ALTER TYPE sms_notice_event ADD VALUE 'sms_receipt'`,
`ALTER TABLE sms_notices ADD COLUMN message_name TEXT UNIQUE NOT NULL`,
`ALTER TABLE sms_notices ADD COLUMN enabled BOOLEAN NOT NULL DEFAULT true`
`ALTER TABLE sms_notices ADD COLUMN enabled BOOLEAN NOT NULL DEFAULT true`,
`ALTER TABLE sms_notices ADD COLUMN allow_toggle BOOLEAN NOT NULL DEFAULT true`
]
db.multi(sql, next)
.then(() => smsNotices.createSMSNotice('sms_code', 'SMS confirmation code', 'Your cryptomat code: #code', true, false))
.then(() => smsNotices.createSMSNotice('cash_out_dispense_ready', 'Cash is ready', 'Your cash is waiting! Go to the Cryptomat and press Redeem within 24 hours. [#timestamp]', true, false))
.then(() => smsNotices.createSMSNotice('sms_receipt', 'SMS receipt', '', true, true))
db.multi(
sql,
() => Promise.all([
smsNotices.createSMSNotice('sms_code', 'SMS confirmation code', 'Your cryptomat code: #code', true, false),
smsNotices.createSMSNotice('cash_out_dispense_ready', 'Cash is ready', 'Your cash is waiting! Go to the Cryptomat and press Redeem within 24 hours. [#timestamp]', true, false),
smsNotices.createSMSNotice('sms_receipt', 'SMS receipt', '', true, true)
])
.then(() => next())
)
}
exports.down = function (next) {