From 83633509c2ca792ef6f36838496463e157d686fd Mon Sep 17 00:00:00 2001 From: Sorrel Bri Date: Thu, 9 Jan 2020 16:16:00 -0800 Subject: [PATCH] add create user table migration --- .../server/migrations/20200109160637_user.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 packages/play-node-go/server/migrations/20200109160637_user.js diff --git a/packages/play-node-go/server/migrations/20200109160637_user.js b/packages/play-node-go/server/migrations/20200109160637_user.js new file mode 100644 index 0000000..a1ded02 --- /dev/null +++ b/packages/play-node-go/server/migrations/20200109160637_user.js @@ -0,0 +1,22 @@ +const rankArray = [ + 'D7', 'D6', 'D5', 'D4', 'D3', 'D2', 'D1', + 'K1', 'K2', 'K3', 'K4', 'K5', 'K6', 'K7', 'K8', 'K9', 'K10', + 'K11', 'K12', 'K13', 'K14', 'K15', 'K16', 'K17', 'K18', 'K19', 'K20', + 'K21', 'K22', 'K23', 'K24', 'K25', 'K26', 'K27', 'K28', 'K29', 'K30', 'UR' +] + +exports.up = knex => { + return knex.schema.createTable("user", table => { + table.increments('id').primary(); + table.string('username').notNullable().unique(); + table.string('email').notNullable().unique(); + table.string('password').notNullable(); + table.boolean('admin').notNullable().defaultTo(false); + table.enu('rank', rankArray).notNullable().defaultTo('UR') + table.integer('elo'); + table.boolean('rank_certainty').defaultTo(false); + table.timestamps(true, true); + }) +}; + +exports.down = knex => knex.schema.dropTableIfExists("user");