diff --git a/packages/server/packages/play-node-go/server/data/migrations/20200120230921_move.js b/packages/server/packages/play-node-go/server/data/migrations/20200120230921_move.js new file mode 100644 index 0000000..c5543d0 --- /dev/null +++ b/packages/server/packages/play-node-go/server/data/migrations/20200120230921_move.js @@ -0,0 +1,17 @@ +const players = ['white', 'black'] + +exports.up = knex => { + return knex.schema.createTable("move", table => { + table.increments('id').primary(); + table.enu('player', players).notNullable(); + table.integer('point_x').notNullable(); + table.integer('point_y').notNullable(); + table.integer('number').notNullable(); + table.boolean('game_record').notNullable().default(true); + + table.integer('game').references('id').inTable('game').notNullable(); + table.integer('prior_move').references('id').inTable('move'); + }); +}; + +exports.down = knex => knex.schema.dropTableIfExists("move"); diff --git a/packages/server/packages/play-node-go/server/data/queries/move.js b/packages/server/packages/play-node-go/server/data/queries/move.js new file mode 100644 index 0000000..e196f0e --- /dev/null +++ b/packages/server/packages/play-node-go/server/data/queries/move.js @@ -0,0 +1,11 @@ +const knex = require('../db'); + +const findGameRecord = async (gameId) => { + return await knex('move') + .where({'game': gameId, 'game_record': true}) + .select('*'); +} + +module.exports = { + findGameRecord +} \ No newline at end of file