fix: normalize SQL
This commit is contained in:
parent
e846f5a165
commit
742913db36
4 changed files with 16 additions and 16 deletions
|
|
@ -3,12 +3,12 @@ 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 using btree(code) where not soft_deleted`
|
||||
`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 USING btree(code) WHERE NOT soft_deleted`
|
||||
]
|
||||
|
||||
db.multi(sql, next)
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ const db = require('./db')
|
|||
|
||||
exports.up = function (next) {
|
||||
var sql = [
|
||||
'alter table cash_in_txs add column discount smallint',
|
||||
'alter table cash_out_txs add column discount smallint'
|
||||
'ALTER TABLE cash_in_txs ADD COLUMN discount SMALLINT',
|
||||
'ALTER TABLE cash_out_txs ADD COLUMN discount SMALLINT'
|
||||
]
|
||||
|
||||
db.multi(sql, next)
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ const db = require('./db')
|
|||
|
||||
exports.up = function (next) {
|
||||
var sql = [
|
||||
'alter table trades add column tx_in_id uuid unique',
|
||||
'alter table trades add constraint fk_tx_in foreign key (tx_in_id) references cash_in_txs (id)',
|
||||
'alter table trades add column tx_out_id uuid unique',
|
||||
'alter table trades add constraint fk_tx_out foreign key (tx_in_id) references cash_out_txs (id)'
|
||||
'ALTER TABLE trades ADD COLUMN tx_in_id UUID UNIQUE',
|
||||
'ALTER TABLE trades ADD CONSTRAINT fk_tx_in FOREIGN KEY (tx_in_id) REFERENCES cash_in_txs (id)',
|
||||
'ALTER TABLE trades ADD COLUMN tx_out_id UUID UNIQUE',
|
||||
'ALTER TABLE trades ADD CONSTRAINT fk_tx_out FOREIGN KEY (tx_in_id) REFERENCES cash_out_txs (id)'
|
||||
]
|
||||
|
||||
db.multi(sql, next)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue