Add transaction versioning, tx cancellation (#79)

This commit is contained in:
Josh Harvey 2017-08-29 16:08:06 +03:00 committed by GitHub
parent 4a97535dec
commit 500edcf279
15 changed files with 2223 additions and 1468 deletions

View file

@ -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()
}

View file

@ -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()
}

View 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()
}

View 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()
}