From f4238303ef629df86fe1f5c61d3b3139f3fa486e Mon Sep 17 00:00:00 2001 From: Josh Harvey Date: Mon, 6 Jun 2016 18:49:56 +0300 Subject: [PATCH] populate user_config in migrations --- migrations/001-initial.js | 60 ++++++++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 10 deletions(-) diff --git a/migrations/001-initial.js b/migrations/001-initial.js index e7ecb8ff..b96f3e79 100644 --- a/migrations/001-initial.js +++ b/migrations/001-initial.js @@ -1,9 +1,43 @@ -'use strict'; +'use strict' -var db = require('./db'); +var db = require('./db') -exports.up = function(next) { +var exchanges = { + exchanges: { + settings: { + commission: 1.0, + compliance: { + maximum: { + limit: null + } + } + }, + plugins: { + current: { + ticker: 'bitpay', + transfer: 'bitgo' + }, + settings: { + bitpay: {}, + bitgo: {} + } + } + } +} +var unit = { + brain: { + locale: { + currency: 'USD', + localeInfo: { + primaryLocale: 'en-US', + primaryLocales: ['en-US'] + } + } + } +} + +exports.up = function (next) { var sqls = [ 'CREATE TABLE IF NOT EXISTS user_config ( ' + 'id serial PRIMARY KEY, ' + @@ -30,12 +64,18 @@ exports.up = function(next) { 'userName text NOT NULL UNIQUE, ' + 'salt text NOT NULL, ' + 'pwdHash text NOT NULL ' + - ')' - ]; + ')', - db.multi(sqls, next); -}; + 'INSERT INTO user_config (type, data) ' + + "VALUES ('exchanges', '" + JSON.stringify(exchanges) + "')", -exports.down = function(next) { - next(); -}; + 'INSERT INTO user_config (type, data) ' + + "VALUES ('unit', '" + JSON.stringify(unit) + "')" + ] + + db.multi(sqls, next) +} + +exports.down = function (next) { + next() +}