aboutsummaryrefslogtreecommitdiffstats
path: root/db/migrations/20210612181508_init_referrals.js
diff options
context:
space:
mode:
authorRan Guin <[email protected]>2021-06-16 22:12:16 -0700
committerRan Guin <[email protected]>2021-06-16 22:12:16 -0700
commit0f7b673325b60b3cb7cbb9cab1a4580655762500 (patch)
tree2ef44958959b458ff423b4345e5817edfbc86eab /db/migrations/20210612181508_init_referrals.js
parent83e4676edf8dff5bd6423e6c860f8a93cda17a79 (diff)
downloadcoinos-server-0f7b673325b60b3cb7cbb9cab1a4580655762500.tar.gz
coinos-server-0f7b673325b60b3cb7cbb9cab1a4580655762500.zip
initialize migrations dir
Diffstat (limited to 'db/migrations/20210612181508_init_referrals.js')
-rw-r--r--db/migrations/20210612181508_init_referrals.js19
1 files changed, 19 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..260a2c8f
--- /dev/null
+++ b/db/migrations/20210612181508_init_referrals.js
@@ -0,0 +1,19 @@
+
+exports.up = function(knex) {
+ return knex.schema.createTable('referrals', function(t) {
+ t.increments('id').unsigned().primary();
+
+ t.string('token').notNull();
+ t.string('expiry').nullable();
+ t.enum('status', ['pending', 'active', 'expired', 'cancelled')).notNull().defaultTo('pending');
+ t.int('sponsor_id').notNull();
+ t.foreign('sponsor_id').references('users.user_id')
+ t.int('user_id').nullable();
+ t.foreign('user_id').references('users.user_id')
+
+ t.timestamps();
+};
+
+exports.down = function(knex) {
+ return knex.schema.dropTable('referrals');
+};