lamassu-server/packages/server/migrations/1603886141913-coupon-codes.js
2025-12-31 19:04:13 +01:00

18 lines
392 B
JavaScript

var db = require('./db')
exports.up = function (next) {
const sql = [
`CREATE TABLE coupons (
id UUID PRIMARY KEY,
code TEXT NOT NULL,
discount SMALLINT NOT NULL,
soft_deleted BOOLEAN DEFAULT false )`,
`CREATE UNIQUE INDEX uq_code ON coupons (code) WHERE NOT soft_deleted`,
]
db.runAll(sql, next)
}
exports.down = function (next) {
next()
}