aboutsummaryrefslogtreecommitdiffstats
path: root/db/migrations/20210612181508_init_referrals.js
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrations/20210612181508_init_referrals.js')
-rw-r--r--db/migrations/20210612181508_init_referrals.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/db/migrations/20210612181508_init_referrals.js b/db/migrations/20210612181508_init_referrals.js
new file mode 100644
index 00000000..875d167f
--- /dev/null
+++ b/db/migrations/20210612181508_init_referrals.js
@@ -0,0 +1,21 @@
+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