From d1c7da98e8ff2031163350b88fa2fd27f4d4ee0d Mon Sep 17 00:00:00 2001 From: Josh Harvey Date: Sun, 11 Jan 2015 16:32:11 -0500 Subject: [PATCH] fix bills migration --- migrations/002-bills.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/migrations/002-bills.js b/migrations/002-bills.js index dc4e43ac..dd7c0bac 100644 --- a/migrations/002-bills.js +++ b/migrations/002-bills.js @@ -3,22 +3,21 @@ var db = require('./db'); exports.up = function(next) { - var sqls = [ - 'CREATE TABLE IF NOT EXISTS bills ( ' + + var sql = + 'CREATE TABLE bills ( ' + 'id uuid PRIMARY KEY, ' + 'device_fingerprint text NOT NULL, ' + 'denomination integer NOT NULL, ' + 'currency_code text NOT NULL, ' + 'satoshis integer NOT NULL, ' + 'to_address text NOT NULL, ' + - 'transaction_id uuid NOT NULL, ' + + 'session_id uuid NOT NULL, ' + 'device_time bigint NOT NULL, ' + - 'created timestamp NOT NULL DEFAULT now() )', + 'created timestamp NOT NULL DEFAULT now() )'; - 'ALTER TABLE bills RENAME COLUMN transaction_id TO session_id' - ]; - - db.multi(sqls, next); + db.silentQuery('ALTER TABLE bills RENAME TO bills_old', function() { + db.query(sql, next); + }); }; exports.down = function(next) {