aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2013-11-13 23:23:20 -0800
committerAdam Soltys <[email protected]>2013-11-13 23:23:20 -0800
commit599a321d9430560e64ac24d167557c5a7f96601b (patch)
treea223b35737e385f6f0f8f8992801c7f90726db3f
parent0b535ef17cb76193b7d67af170b7bc3a9cfb29e6 (diff)
downloadcoinos-server-599a321d9430560e64ac24d167557c5a7f96601b.tar.gz
coinos-server-599a321d9430560e64ac24d167557c5a7f96601b.zip
Postgres migrations
-rw-r--r--migrations/20131110050923-add-users.js15
-rw-r--r--migrations/20131110070704-add-merchants.js16
-rw-r--r--migrations/20131110070755-add-addresses.js14
-rw-r--r--migrations/20131110070850-add-orders.js23
-rw-r--r--migrations/20131110070913-add-settlements.js19
-rw-r--r--migrations/20131110233123-add-exchanges.js14
-rw-r--r--migrations/20131110233243-add-settlers.js16
-rw-r--r--migrations/20131110234112-add-exchanges_settlers.js14
-rw-r--r--migrations/20131110235240-add-methods.js13
-rw-r--r--migrations/20131110235504-add-methods_settlers.js13
10 files changed, 144 insertions, 13 deletions
diff --git a/migrations/20131110050923-add-users.js b/migrations/20131110050923-add-users.js
index 47911db8..f22dabc2 100644
--- a/migrations/20131110050923-add-users.js
+++ b/migrations/20131110050923-add-users.js
@@ -3,21 +3,10 @@ var type = dbm.dataType;
exports.up = function(db, callback) {
db.createTable('users', {
- id: { type: 'int', primaryKey: true },
+ id: { type: 'int', primaryKey: true, autoIncrement: true },
username: { type: 'string' },
password: { type: 'string' },
- first_name: { type: 'string' },
- last_name: { type: 'string' },
- email: { type: 'string' },
- phone: { type: 'string' },
- company: { type: 'string' },
- category: { type: 'string' },
- website: { type: 'string' },
- location: { type: 'string' },
- city: { type: 'string' },
- postal_code: { type: 'string' },
- province: { type: 'string' },
- country: { type: 'string' }
+ last_login: { type: 'datetime' }
}, callback);
};
diff --git a/migrations/20131110070704-add-merchants.js b/migrations/20131110070704-add-merchants.js
new file mode 100644
index 00000000..61e718f4
--- /dev/null
+++ b/migrations/20131110070704-add-merchants.js
@@ -0,0 +1,16 @@
+var dbm = require('db-migrate');
+var type = dbm.dataType;
+
+exports.up = function(db, callback) {
+ db.createTable('merchants', {
+ user_id: { type: 'int', primaryKey: true },
+ formula: { type: 'string' },
+ limit: { type: 'decimal' }
+ }, callback);
+
+ db.runSql('ALTER TABLE merchants ALTER COLUMN "limit" type decimal(10,2);');
+};
+
+exports.down = function(db, callback) {
+ db.dropTable('merchants', callback);
+};
diff --git a/migrations/20131110070755-add-addresses.js b/migrations/20131110070755-add-addresses.js
new file mode 100644
index 00000000..4415d327
--- /dev/null
+++ b/migrations/20131110070755-add-addresses.js
@@ -0,0 +1,14 @@
+var dbm = require('db-migrate');
+var type = dbm.dataType;
+
+exports.up = function(db, callback) {
+ db.createTable('addresses', {
+ id: { type: 'int', primaryKey: true, autoIncrement: true },
+ merchant_id: { type: 'int' },
+ address: { type: 'string' }
+ }, callback);
+};
+
+exports.down = function(db, callback) {
+ db.dropTable('addresses', callback);
+};
diff --git a/migrations/20131110070850-add-orders.js b/migrations/20131110070850-add-orders.js
new file mode 100644
index 00000000..39b31139
--- /dev/null
+++ b/migrations/20131110070850-add-orders.js
@@ -0,0 +1,23 @@
+var dbm = require('db-migrate');
+var async = require('async');
+var type = dbm.dataType;
+
+exports.up = function(db, callback) {
+ async.series([
+ db.createTable('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('ALTER TABLE orders ALTER COLUMN amount type decimal(10,2);', callback),
+ db.runSql('ALTER TABLE orders ALTER COLUMN rate type decimal(10,2);', callback)
+ ]);
+};
+
+exports.down = function(db, callback) {
+ db.dropTable('orders', callback);
+};
diff --git a/migrations/20131110070913-add-settlements.js b/migrations/20131110070913-add-settlements.js
new file mode 100644
index 00000000..7c835f87
--- /dev/null
+++ b/migrations/20131110070913-add-settlements.js
@@ -0,0 +1,19 @@
+var dbm = require('db-migrate');
+var type = dbm.dataType;
+
+exports.up = function(db, callback) {
+ db.createTable('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);');
+};
+
+exports.down = function(db, callback) {
+ db.dropTable('settlements', callback);
+};
diff --git a/migrations/20131110233123-add-exchanges.js b/migrations/20131110233123-add-exchanges.js
new file mode 100644
index 00000000..a7e824c3
--- /dev/null
+++ b/migrations/20131110233123-add-exchanges.js
@@ -0,0 +1,14 @@
+var dbm = require('db-migrate');
+var type = dbm.dataType;
+
+exports.up = function(db, callback) {
+ db.createTable('exchanges', {
+ id: { type: 'int', primaryKey: true, autoIncrement: true },
+ name: { type: 'string' },
+ url: { type: 'string' }
+ }, callback);
+};
+
+exports.down = function(db, callback) {
+ db.dropTable('exchanges', callback);
+};
diff --git a/migrations/20131110233243-add-settlers.js b/migrations/20131110233243-add-settlers.js
new file mode 100644
index 00000000..b163c5c2
--- /dev/null
+++ b/migrations/20131110233243-add-settlers.js
@@ -0,0 +1,16 @@
+var dbm = require('db-migrate');
+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);');
+};
+
+exports.down = function(db, callback) {
+ db.dropTable('settlers', callback);
+};
diff --git a/migrations/20131110234112-add-exchanges_settlers.js b/migrations/20131110234112-add-exchanges_settlers.js
new file mode 100644
index 00000000..31ec74b0
--- /dev/null
+++ b/migrations/20131110234112-add-exchanges_settlers.js
@@ -0,0 +1,14 @@
+var dbm = require('db-migrate');
+var type = dbm.dataType;
+
+exports.up = function(db, callback) {
+ db.createTable('exchanges_settlers', {
+ user_id: { type: 'int' },
+ exchange_id: { type: 'int' },
+ api_key: { type: 'string' }
+ }, callback);
+};
+
+exports.down = function(db, callback) {
+ db.dropTable('exchanges_settlers');
+};
diff --git a/migrations/20131110235240-add-methods.js b/migrations/20131110235240-add-methods.js
new file mode 100644
index 00000000..80289812
--- /dev/null
+++ b/migrations/20131110235240-add-methods.js
@@ -0,0 +1,13 @@
+var dbm = require('db-migrate');
+var type = dbm.dataType;
+
+exports.up = function(db, callback) {
+ db.createTable('methods', {
+ id: { type: 'int', primaryKey: true, autoIncrement: true },
+ name: { type: 'string' }
+ }, callback);
+};
+
+exports.down = function(db, callback) {
+ db.dropTable('methods');
+};
diff --git a/migrations/20131110235504-add-methods_settlers.js b/migrations/20131110235504-add-methods_settlers.js
new file mode 100644
index 00000000..409b80e3
--- /dev/null
+++ b/migrations/20131110235504-add-methods_settlers.js
@@ -0,0 +1,13 @@
+var dbm = require('db-migrate');
+var type = dbm.dataType;
+
+exports.up = function(db, callback) {
+ db.createTable('methods_settlers', {
+ method_id: { type: 'int' },
+ settler_id: { type: 'int' }
+ }, callback);
+};
+
+exports.down = function(db, callback) {
+ db.dropTable('methods_settlers', callback);
+};