aboutsummaryrefslogtreecommitdiffstats
path: root/db/migrations/20210612181508_init_referrals.js
blob: 875d167f7cbdc78ddaa9373c5d62455f9778bcf9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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');
      };