add message table with migration

This commit is contained in:
Sorrel Bri 2020-01-20 23:36:52 -08:00
parent a10453a848
commit 5205035d7c
3 changed files with 27 additions and 0 deletions

View file

@ -14,6 +14,7 @@ exports.up = function(knex) {
table.string('application');
table.string('application_version');
table.timestamps(true, true);
table.string('player_black');
table.string('player_white');

View file

@ -0,0 +1,13 @@
exports.up = knex => {
return knex.schema.createTable("message", table => {
table.increments('id').primary();
table.timestamps(true, true)
table.text('content').notNullable();
table.integer('move').references('id').inTable('move');
table.integer('room').references('id').inTable('room');
table.integer('user').references('id').inTable('user').notNullable();
});
};
exports.down = knex => knex.schema.dropTableIfExists("message");

View file

@ -0,0 +1,13 @@
const knex = require('../db');
// TODO timestamps
const findMessageByRoom = async (roomId) => {
return await knex('message')
.where({'id': roomId})
.select('*');
}
module.exports = {
findMessageByRoom
}