diff options
| author | Adam Soltys <[email protected]> | 2013-11-14 09:34:51 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2013-11-14 09:34:51 -0800 |
| commit | 8e6b6805c4bc8493f8108f896ccf4f67dbd0b95d (patch) | |
| tree | ac54d4709e6055492a5d442ac4db50a9f4dc175c /migrations | |
| parent | 3ce3847a265b08789a7465d0ab7ec8cf903a81a7 (diff) | |
| download | coinos-server-8e6b6805c4bc8493f8108f896ccf4f67dbd0b95d.tar.gz coinos-server-8e6b6805c4bc8493f8108f896ccf4f67dbd0b95d.zip | |
Use async to run migration commands in series
Diffstat (limited to 'migrations')
| -rw-r--r-- | migrations/20131110070704-add-merchants.js | 4 | ||||
| -rw-r--r-- | migrations/20131110070850-add-orders.js | 6 | ||||
| -rw-r--r-- | migrations/20131110070913-add-settlements.js | 10 | ||||
| -rw-r--r-- | migrations/20131110233243-add-settlers.js | 16 |
4 files changed, 20 insertions, 16 deletions
diff --git a/migrations/20131110070704-add-merchants.js b/migrations/20131110070704-add-merchants.js index a4f3f7dd..15d0515c 100644 --- a/migrations/20131110070704-add-merchants.js +++ b/migrations/20131110070704-add-merchants.js @@ -3,12 +3,12 @@ var async = require('async'); var type = dbm.dataType; exports.up = function(db, callback) { - async.series([db.bind.createTable('merchants', { + async.series([db.createTable.bind(db, 'merchants', { user_id: { type: 'int', primaryKey: true }, formula: { type: 'string' }, limit: { type: 'decimal' } }), - db.runSql('ALTER TABLE merchants ALTER COLUMN "limit" type decimal(10,2);') + db.runSql.bind(db, 'ALTER TABLE merchants ALTER COLUMN "limit" type decimal(10,2);') ], callback); }; diff --git a/migrations/20131110070850-add-orders.js b/migrations/20131110070850-add-orders.js index b0a7d474..e6f94246 100644 --- a/migrations/20131110070850-add-orders.js +++ b/migrations/20131110070850-add-orders.js @@ -4,7 +4,7 @@ var type = dbm.dataType; exports.up = function(db, callback) { async.series([ - db.createTable('orders', { + db.createTable.bind(db, 'orders', { id: { type: 'int', primaryKey: true, autoIncrement: true }, merchant_id: { type: 'int' }, amount: { type: 'decimal' }, @@ -13,8 +13,8 @@ exports.up = function(db, callback) { creation_time: { type: 'datetime' }, expiration_time: { type: 'datetime' } }), - db.runSql('ALTER TABLE orders ALTER COLUMN amount type decimal(10,2);'), - db.runSql('ALTER TABLE orders ALTER COLUMN rate type decimal(10,2);') + db.runSql.bind(db, 'ALTER TABLE orders ALTER COLUMN amount type decimal(10,2);'), + db.runSql.bind(db, 'ALTER TABLE orders ALTER COLUMN rate type decimal(10,2);') ], callback); }; diff --git a/migrations/20131110070913-add-settlements.js b/migrations/20131110070913-add-settlements.js index 7c835f87..c66ee863 100644 --- a/migrations/20131110070913-add-settlements.js +++ b/migrations/20131110070913-add-settlements.js @@ -1,17 +1,19 @@ var dbm = require('db-migrate'); +var async = require('async'); var type = dbm.dataType; exports.up = function(db, callback) { - db.createTable('settlements', { + async.series([ + db.createTable.bind(db, 'settlements', { id: { type: 'int', primaryKey: true, autoIncrement: true }, settler_id: { type: 'int' }, merchant_id: { type: 'int' }, amount: { type: 'decimal' }, date: { type: 'datetime' }, method: { type: 'string' } - }, callback); - - db.runSql('ALTER TABLE settlements ALTER COLUMN amount type decimal(10,2);'); + }), + db.runSql.bind(db, 'ALTER TABLE settlements ALTER COLUMN amount type decimal(10,2);') + ], callback); }; exports.down = function(db, callback) { diff --git a/migrations/20131110233243-add-settlers.js b/migrations/20131110233243-add-settlers.js index b163c5c2..97575bce 100644 --- a/migrations/20131110233243-add-settlers.js +++ b/migrations/20131110233243-add-settlers.js @@ -1,14 +1,16 @@ var dbm = require('db-migrate'); +var async = require('async'); var type = dbm.dataType; exports.up = function(db, callback) { - db.createTable('settlers', { - user_id: { type: 'int', primaryKey: true }, - formula: { type: 'string' }, - reserve: { type: 'decimal' } - }, callback); - - db.runSql('ALTER TABLE settlers ALTER COLUMN reserve type decimal(10,2);'); + async.series([ + db.createTable.bind(db, 'settlers', { + user_id: { type: 'int', primaryKey: true }, + formula: { type: 'string' }, + reserve: { type: 'decimal' } + }), + db.runSql.bind(db, 'ALTER TABLE settlers ALTER COLUMN reserve type decimal(10,2);') + ], callback); }; exports.down = function(db, callback) { |
