clean up migrations
This commit is contained in:
parent
236070668a
commit
279c296aee
8 changed files with 25 additions and 103 deletions
|
|
@ -1,46 +1,4 @@
|
||||||
'use strict'
|
const db = require('./db')
|
||||||
|
|
||||||
var db = require('./db')
|
|
||||||
|
|
||||||
var exchanges = {
|
|
||||||
exchanges: {
|
|
||||||
settings: {
|
|
||||||
commission: 1.0,
|
|
||||||
compliance: {
|
|
||||||
maximum: {
|
|
||||||
limit: null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
plugins: {
|
|
||||||
current: {
|
|
||||||
BTC: {
|
|
||||||
ticker: 'bitpay',
|
|
||||||
transfer: 'bitgo'
|
|
||||||
},
|
|
||||||
email: 'smtp2go',
|
|
||||||
sms: 'twilio',
|
|
||||||
notify: []
|
|
||||||
},
|
|
||||||
settings: {
|
|
||||||
bitpay: {},
|
|
||||||
bitgo: {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var unit = {
|
|
||||||
brain: {
|
|
||||||
locale: {
|
|
||||||
currency: 'USD',
|
|
||||||
localeInfo: {
|
|
||||||
primaryLocale: 'en-US',
|
|
||||||
primaryLocales: ['en-US']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
var sqls = [
|
var sqls = [
|
||||||
|
|
@ -69,13 +27,7 @@ exports.up = function (next) {
|
||||||
'userName text NOT NULL UNIQUE, ' +
|
'userName text NOT NULL UNIQUE, ' +
|
||||||
'salt text NOT NULL, ' +
|
'salt text NOT NULL, ' +
|
||||||
'pwdHash text NOT NULL ' +
|
'pwdHash text NOT NULL ' +
|
||||||
')',
|
')'
|
||||||
|
|
||||||
'INSERT INTO user_config (type, data) ' +
|
|
||||||
"VALUES ('exchanges', '" + JSON.stringify(exchanges) + "')",
|
|
||||||
|
|
||||||
'INSERT INTO user_config (type, data) ' +
|
|
||||||
"VALUES ('unit', '" + JSON.stringify(unit) + "')"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
db.multi(sqls, next)
|
db.multi(sqls, next)
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,14 @@
|
||||||
'use strict';
|
var db = require('./db')
|
||||||
|
|
||||||
var db = require('./db');
|
function singleQuotify (item) { return '\'' + item + '\'' }
|
||||||
|
|
||||||
function singleQuotify(item) { return '\'' + item + '\''; }
|
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
var stages = ['initial_request', 'partial_request', 'final_request',
|
var stages = ['initial_request', 'partial_request', 'final_request',
|
||||||
'partial_send', 'deposit', 'dispense_request', 'dispense'].
|
'partial_send', 'deposit', 'dispense_request', 'dispense']
|
||||||
map(singleQuotify).join(',');
|
.map(singleQuotify).join(',')
|
||||||
|
|
||||||
var authorizations = ['timeout', 'machine', 'pending', 'rejected',
|
var authorizations = ['timeout', 'machine', 'pending', 'rejected',
|
||||||
'published', 'authorized', 'confirmed'].map(singleQuotify).join(',');
|
'published', 'authorized', 'confirmed'].map(singleQuotify).join(',')
|
||||||
|
|
||||||
var sqls = [
|
var sqls = [
|
||||||
'CREATE TYPE transaction_stage AS ENUM (' + stages + ')',
|
'CREATE TYPE transaction_stage AS ENUM (' + stages + ')',
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
var db = require('./db')
|
var db = require('./db')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
db.query('CREATE TABLE IF NOT EXISTS machine_configs ( ' +
|
db.multi(['CREATE TABLE IF NOT EXISTS machine_configs ( ' +
|
||||||
'id serial PRIMARY KEY, ' +
|
'id serial PRIMARY KEY, ' +
|
||||||
'device_fingerprint text NOT NULL, ' +
|
'device_fingerprint text NOT NULL, ' +
|
||||||
'data json NOT NULL )', next)
|
'data json NOT NULL )'], next)
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.down = function (next) {
|
exports.down = function (next) {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
var db = require('./db')
|
var db = require('./db')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
db.query('CREATE TABLE IF NOT EXISTS cached_responses ( ' +
|
db.multi(['CREATE TABLE IF NOT EXISTS cached_responses ( ' +
|
||||||
'id serial PRIMARY KEY, ' +
|
'id serial PRIMARY KEY, ' +
|
||||||
'device_fingerprint text NOT NULL, ' +
|
'device_fingerprint text NOT NULL, ' +
|
||||||
'session_id uuid NOT NULL, ' +
|
'session_id uuid NOT NULL, ' +
|
||||||
|
|
@ -12,7 +12,7 @@ exports.up = function (next) {
|
||||||
'body json NOT NULL, ' +
|
'body json NOT NULL, ' +
|
||||||
'created timestamptz NOT NULL DEFAULT now(), ' +
|
'created timestamptz NOT NULL DEFAULT now(), ' +
|
||||||
'UNIQUE (device_fingerprint, session_id, path, method) ' +
|
'UNIQUE (device_fingerprint, session_id, path, method) ' +
|
||||||
')', next)
|
')'], next)
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.down = function (next) {
|
exports.down = function (next) {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ var db = require('./db')
|
||||||
|
|
||||||
exports.up = function (next) {
|
exports.up = function (next) {
|
||||||
var sql = [
|
var sql = [
|
||||||
'delete from user_config',
|
|
||||||
'alter table user_config add column valid boolean not null'
|
'alter table user_config add column valid boolean not null'
|
||||||
]
|
]
|
||||||
db.multi(sql, next)
|
db.multi(sql, next)
|
||||||
|
|
|
||||||
|
|
@ -1,43 +1,10 @@
|
||||||
'use strict';
|
const db = require('../lib/db')
|
||||||
|
const sequential = require('promise-sequential')
|
||||||
|
|
||||||
var pg = require('pg');
|
module.exports = {multi}
|
||||||
var async = require('async');
|
|
||||||
var psqlUrl = require('../lib/options').postgresql
|
|
||||||
|
|
||||||
if (!psqlUrl) {
|
function multi (sqls, cb) {
|
||||||
console.log('No postgresql entry in config file')
|
return sequential(sqls.map(s => db.none(s)))
|
||||||
process.exit(1)
|
.then(cb)
|
||||||
|
.catch(cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.query = function query(sql, cb) {
|
|
||||||
exports.multi([sql], cb);
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.silentQuery = function query(sql, cb) {
|
|
||||||
pg.connect(psqlUrl, function(err, client, done) {
|
|
||||||
if (err) {
|
|
||||||
console.log(err.message);
|
|
||||||
return cb(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
client.query(sql, function(err) {
|
|
||||||
done(true);
|
|
||||||
cb(err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.multi = function multi(sqls, cb) {
|
|
||||||
pg.connect(psqlUrl, function(err, client, done) {
|
|
||||||
if (err) {
|
|
||||||
console.log(err.message);
|
|
||||||
return cb(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
async.eachSeries(sqls, client.query.bind(client), function(err) {
|
|
||||||
done(true);
|
|
||||||
if (err) console.log(err);
|
|
||||||
cb(err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@
|
||||||
"pg-promise": "^5.6.4",
|
"pg-promise": "^5.6.4",
|
||||||
"pify": "^2.3.0",
|
"pify": "^2.3.0",
|
||||||
"pretty-ms": "^2.1.0",
|
"pretty-ms": "^2.1.0",
|
||||||
|
"promise-sequential": "^1.1.1",
|
||||||
"ramda": "^0.22.1",
|
"ramda": "^0.22.1",
|
||||||
"serve-static": "^1.11.1",
|
"serve-static": "^1.11.1",
|
||||||
"socket.io": "^1.7.1",
|
"socket.io": "^1.7.1",
|
||||||
|
|
|
||||||
|
|
@ -3701,6 +3701,10 @@ process-nextick-args@~1.0.6:
|
||||||
version "1.0.7"
|
version "1.0.7"
|
||||||
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3"
|
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3"
|
||||||
|
|
||||||
|
promise-sequential@^1.1.1:
|
||||||
|
version "1.1.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/promise-sequential/-/promise-sequential-1.1.1.tgz#f79e8950ef86e7a7a85bf320452643592f6d2fb2"
|
||||||
|
|
||||||
proxy-addr@~1.1.3:
|
proxy-addr@~1.1.3:
|
||||||
version "1.1.4"
|
version "1.1.4"
|
||||||
resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-1.1.4.tgz#27e545f6960a44a627d9b44467e35c1b6b4ce2f3"
|
resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-1.1.4.tgz#27e545f6960a44a627d9b44467e35c1b6b4ce2f3"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue