format for latest standard

This commit is contained in:
Josh Harvey 2018-03-10 18:59:40 +00:00
parent 4108efd9c7
commit c2af183911
77 changed files with 1697 additions and 1693 deletions

View file

@ -5,7 +5,7 @@ function singleQuotify (item) { return '\'' + item + '\'' }
exports.up = function (next) {
var statuses = ['notSeen', 'published', 'authorized', 'instant',
'confirmed', 'rejected', 'insufficientFunds']
.map(singleQuotify).join(',')
.map(singleQuotify).join(',')
var sql = [
'create type status_stage AS enum (' + statuses + ')',

View file

@ -4,9 +4,9 @@ function singleQuotify (item) { return '\'' + item + '\'' }
exports.up = function (next) {
var actions = ['published', 'authorized', 'instant', 'confirmed', 'rejected',
'insufficientFunds', 'dispenseRequested', 'dispensed', 'notified',
'addedPhone', 'redeem']
.map(singleQuotify).join(',')
'insufficientFunds', 'dispenseRequested', 'dispensed', 'notified',
'addedPhone', 'redeem']
.map(singleQuotify).join(',')
var sql = [
`create table cash_in_txs (

View file

@ -23,7 +23,7 @@ exports.up = function (next) {
`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}'`
]
]
db.multi(sql, next)
}

View file

@ -3,7 +3,7 @@ var db = require('./db')
exports.up = function (next) {
const sql =
[ "create type compliance_types as enum ('manual', 'sanctions', 'sanctions_override')",
`create table compliance_authorizations (
`create table compliance_authorizations (
id uuid PRIMARY KEY,
customer_id uuid REFERENCES customers (id),
compliance_type compliance_types NOT NULL,

View file

@ -6,7 +6,7 @@ exports.up = function (next) {
id uuid PRIMARY KEY,
device_id text,
timestamp timestamptz not null default now() )`,
'alter table logs add column server_timestamp timestamptz not null default now() '
'alter table logs add column server_timestamp timestamptz not null default now() '
]
db.multi(sql, next)

View file

@ -3,23 +3,23 @@ const migrateTools = require('./migrate-tools')
exports.up = function (next) {
return migrateTools.migrateNames()
.then(updateSql => {
const sql = [
'alter table devices add column name text',
updateSql,
'alter table devices alter column name set not null'
]
.then(updateSql => {
const sql = [
'alter table devices add column name text',
updateSql,
'alter table devices alter column name set not null'
]
return db.multi(sql, next)
})
.catch(() => {
const sql = [
'alter table devices add column name text',
'alter table devices alter column name set not null'
]
return db.multi(sql, next)
})
.catch(() => {
const sql = [
'alter table devices add column name text',
'alter table devices alter column name set not null'
]
return db.multi(sql, next)
})
return db.multi(sql, next)
})
}
exports.down = function (next) {

View file

@ -7,17 +7,17 @@ function multi (sqls, cb) {
const doQuery = s => {
return () => {
return db.none(s)
.catch(err => {
console.log(err.stack)
throw err
})
.catch(err => {
console.log(err.stack)
throw err
})
}
}
return sequential(sqls.map(doQuery))
.then(() => cb())
.catch(err => {
console.log(err.stack)
cb(err)
})
.then(() => cb())
.catch(err => {
console.log(err.stack)
cb(err)
})
}

View file

@ -10,7 +10,7 @@ function migrateNames () {
const cs = new pgp.helpers.ColumnSet(['device_id', 'name'], {table: 'devices'})
return settingsLoader.loadLatest()
.then(r => machineLoader.getMachineNames(r.config))
.then(_.map(r => ({device_id: r.deviceId, name: r.name})))
.then(data => pgp.helpers.update(data, cs))
.then(r => machineLoader.getMachineNames(r.config))
.then(_.map(r => ({device_id: r.deviceId, name: r.name})))
.then(data => pgp.helpers.update(data, cs))
}