export const addUserSearch = function(input, table) { var { search, starts_with, contains } = input; if (!table) { table = "users"; } // if (since) cmd = cmd.havingRaw('invoices + payments + deposits + orders > ?', [0]) if (search) { if (starts_with) { search = search + "%"; } else if (contains) { search = "%" + search + "%"; } var condition = "(" + table + ".email like '" + search + "' OR " + table + ".username like '" + search + "')"; return condition; } else { return ""; } }; export const addTimeSearch = function(input, field) { if (!field) { field = "updatedAt"; } var { since } = input; if (since) { condition = field + " >= '" + since + "'"; return condition; } else { return ""; } }; 5fae55fc32a8582ce8b77ea097bfdb2b53'/> coinos server — legacy coinos.io backend (Lightning, on-chain, Liquid)coinos
aboutsummaryrefslogtreecommitdiffstats
path: root/db/normalized/referrals.js
blob: f09c98f40cf375cb9e09bc5a136dfa386500d952 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
exports.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();
  })
};

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