aboutsummaryrefslogtreecommitdiffstats
path: root/db/normalized/referrals.js
blob: 7380f2cf6d701ed4282b059d7a7a09b6b6dfab0f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
export const up = function(knex) {
  return knex.schema.createTable('referrals', function(t) {
    t.increments('id').unsigned().primary();
    t.int('user_id').nullable();
    t.foreign('user_id').references('users.id');

    t.int('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();
  })
};

export const down = function(knex) {
  return knex.schema.dropTable('referrals');
};