aboutsummaryrefslogtreecommitdiffstats
path: root/db/migrations/20210612181508_init_referrals.js
diff options
context:
space:
mode:
authorRan Guin <[email protected]>2021-07-28 16:25:07 -0700
committerAdam Soltys <[email protected]>2021-07-29 11:55:26 -0700
commitfc19ca29073fc4fc193af583dde6a9e15fa776ba (patch)
tree660eb581be06a1a29bb884ecc0c43b497cfb3a57 /db/migrations/20210612181508_init_referrals.js
parent310b1c52620e64e89e0886c160db60b64dfd7429 (diff)
downloadcoinos-server-fc19ca29073fc4fc193af583dde6a9e15fa776ba.tar.gz
coinos-server-fc19ca29073fc4fc193af583dde6a9e15fa776ba.zip
tweak user_id reference
Diffstat (limited to 'db/migrations/20210612181508_init_referrals.js')
-rw-r--r--db/migrations/20210612181508_init_referrals.js43
1 files changed, 23 insertions, 20 deletions
diff --git a/db/migrations/20210612181508_init_referrals.js b/db/migrations/20210612181508_init_referrals.js
index 875d167f..f9107e15 100644
--- a/db/migrations/20210612181508_init_referrals.js
+++ b/db/migrations/20210612181508_init_referrals.js
@@ -1,21 +1,24 @@
exports.up = function(knex) {
- return knex.schema.createTable('referrals', function(t) {
- t.increments('id').unsigned().primary();
- t.integer('user_id').nullable();
- t.foreign('user_id').references('users.id');
-
- t.integer('sponsor_id').notNull();
- t.foreign('sponsor_id').references('users.id');
-
- t.string('token').notNull();
- t.string('expiry').nullable();
- t.enum('status', ['available', 'used', 'expired', 'cancelled']).notNull().defaultTo('available');
-
- t.timestamps();
- })
- };
-
- exports.down = function(knex) {
- return knex.schema.dropTable('referrals');
- };
- \ No newline at end of file
+ return Promise.all([
+ knex.schema.dropTableIfExists('referrals'),
+
+ knex.schema.createTable('referrals', function(t) {
+ t.increments('id').unsigned().primary();
+ t.integer('user_id').nullable();
+ t.foreign('user_id').references('users.id');
+
+ t.integer('sponsor_id').notNull();
+ t.foreign('sponsor_id').references('users.id');
+
+ t.string('token').notNull();
+ t.string('expiry').nullable();
+ t.enum('status', ['available', 'used', 'expired', 'cancelled']).notNull().defaultTo('available');
+
+ t.timestamps();
+ })
+ ])
+};
+
+exports.down = function(knex) {
+ return knex.schema.dropTable('referrals');
+};