aboutsummaryrefslogtreecommitdiffstats
path: root/migrations/20131110070850-add-orders.js
blob: e6f94246cb6fa3520a33e35cc47c0a6c40b3a1ac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var dbm = require('db-migrate');
var async = require('async');
var type = dbm.dataType;

exports.up = function(db, callback) {
  async.series([
    db.createTable.bind(db, 'orders', {
      id: { type: 'int', primaryKey: true, autoIncrement: true },
      merchant_id: { type: 'int' },
      amount: { type: 'decimal' },
      rate: { type: 'decimal' }, 
      status: { type: 'int' },
      creation_time: { type: 'datetime' },
      expiration_time: { type: 'datetime' }
    }),
    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);
};

exports.down = function(db, callback) {
  db.dropTable('orders', callback);
};