Add transaction versioning, tx cancellation (#79)
This commit is contained in:
parent
4a97535dec
commit
500edcf279
15 changed files with 2223 additions and 1468 deletions
|
|
@ -1,10 +1,9 @@
|
|||
var db = require('./db')
|
||||
var anonymous = require('../lib/constants').anonymousCustomer
|
||||
|
||||
exports.up = function(next) {
|
||||
exports.up = function (next) {
|
||||
const sql =
|
||||
[
|
||||
`create table customers (
|
||||
[`create table customers (
|
||||
id uuid PRIMARY KEY,
|
||||
phone text unique,
|
||||
phone_at timestamptz,
|
||||
|
|
@ -23,12 +22,12 @@ exports.up = function(next) {
|
|||
created timestamptz NOT NULL DEFAULT now() )`,
|
||||
`insert into customers (id, name) VALUES ( '${anonymous.uuid}','${anonymous.name}' )`,
|
||||
`alter table cash_in_txs add column customer_id uuid references customers (id) DEFAULT '${anonymous.uuid}'`,
|
||||
`alter table cash_out_txs add column customer_id uuid references customers (id) DEFAULT '${anonymous.uuid}'`,
|
||||
`alter table cash_out_txs add column customer_id uuid references customers (id) DEFAULT '${anonymous.uuid}'`
|
||||
]
|
||||
|
||||
db.multi(sql, next)
|
||||
};
|
||||
}
|
||||
|
||||
exports.down = function(next) {
|
||||
next();
|
||||
};
|
||||
exports.down = function (next) {
|
||||
next()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,18 @@
|
|||
var db = require('./db')
|
||||
|
||||
exports.up = function(next) {
|
||||
exports.up = function (next) {
|
||||
const sql =
|
||||
[`create type compliance_types as enum ('manual', 'sanctions', 'sanctions_override') `,
|
||||
`create table compliance_authorizations (
|
||||
id uuid PRIMARY KEY,
|
||||
customer_id uuid REFERENCES customers (id),
|
||||
[ "create type compliance_types as enum ('manual', 'sanctions', 'sanctions_override')",
|
||||
`create table compliance_authorizations (
|
||||
id uuid PRIMARY KEY,
|
||||
customer_id uuid REFERENCES customers (id),
|
||||
compliance_type compliance_types NOT NULL,
|
||||
authorized_at timestamptz NOT NULL,
|
||||
authorized_by text REFERENCES user_tokens (token) )` ]
|
||||
|
||||
|
||||
db.multi(sql, next)
|
||||
};
|
||||
}
|
||||
|
||||
exports.down = function(next) {
|
||||
next();
|
||||
};
|
||||
exports.down = function (next) {
|
||||
next()
|
||||
}
|
||||
|
|
|
|||
14
migrations/1503907708756-drop-device-time.js
Normal file
14
migrations/1503907708756-drop-device-time.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
var db = require('./db')
|
||||
|
||||
exports.up = function (next) {
|
||||
const sql = [
|
||||
'alter table cash_in_txs drop column device_time',
|
||||
'alter table cash_out_txs drop column device_time'
|
||||
]
|
||||
|
||||
db.multi(sql, next)
|
||||
}
|
||||
|
||||
exports.down = function (next) {
|
||||
next()
|
||||
}
|
||||
14
migrations/1503945570220-add-tx-version.js
Normal file
14
migrations/1503945570220-add-tx-version.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
var db = require('./db')
|
||||
|
||||
exports.up = function (next) {
|
||||
const sql = [
|
||||
'alter table cash_in_txs add column tx_version integer not null',
|
||||
'alter table cash_out_txs add column tx_version integer not null'
|
||||
]
|
||||
|
||||
db.multi(sql, next)
|
||||
}
|
||||
|
||||
exports.down = function (next) {
|
||||
next()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue