feat: individual discounts migration

feat: loyalty panel routing
chore: rename promo-codes module to loyalty
This commit is contained in:
Sérgio Salgado 2021-07-22 01:15:01 +01:00 committed by Josh Harvey
parent 576979f14f
commit 07f15db851
14 changed files with 183 additions and 55 deletions

View file

@ -0,0 +1,21 @@
var db = require('./db')
exports.up = function (next) {
var sql = [
`CREATE TYPE individual_discount_identification_type AS ENUM('phone', 'id_number')`,
`CREATE TABLE individual_discounts (
id UUID PRIMARY KEY,
identification individual_discount_identification_type NOT NULL,
value TEXT NOT NULL,
discount SMALLINT NOT NULL,
soft_deleted BOOLEAN DEFAULT false
)`,
`CREATE UNIQUE INDEX uq_individual_discount ON individual_discounts (value) WHERE NOT soft_deleted`
]
db.multi(sql, next)
}
exports.down = function (next) {
next()
}