node-go/server/data/migrations/20200120224032_game.js

49 lines
1.6 KiB
JavaScript
Raw Permalink Normal View History

2020-01-21 07:05:55 +00:00
const winType = [
'B+R', 'B+', 'B+T',
'W+R', 'W+', 'W+T',
'0', 'Void', '?'
]
const rankArray = [
'D9', 'D8', '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'
]
2020-01-21 07:05:55 +00:00
exports.up = function(knex) {
return knex.schema.createTable("game", table => {
table.increments('id').primary();
table.datetime('date');
table.float('komi').default(6.5);
table.integer('handicap').default(0);
table.integer('board_size').default(19);
2020-01-24 00:04:40 +00:00
table.boolean('open').default(true);
2020-01-21 07:05:55 +00:00
table.string('application');
table.string('application_version');
2020-01-21 07:36:52 +00:00
table.timestamps(true, true);
2020-01-21 07:05:55 +00:00
table.string('player_black');
table.string('player_white');
table.enu('player_black_rank', rankArray).default('UR');
table.enu('player_white_rank', rankArray).default('UR');
2020-01-21 07:05:55 +00:00
table.string('event');
table.string('name');
table.string('description');
table.integer('round');
table.enu('win_type', winType);
table.float('score');
table.integer('black_captures');
table.integer('white_captures');
table.integer('user_black').references('id').inTable('user');
table.integer('user_white').references('id').inTable('user');
table.integer('room').references('id').inTable('room');
table.integer('time_setting').references('id').inTable('time_setting');
})
};
exports.down = knex => knex.schema.dropTableIfExists("game");