add message table with migration
This commit is contained in:
parent
464a8ffbf4
commit
e8867b9634
3 changed files with 27 additions and 0 deletions
|
@ -14,6 +14,7 @@ exports.up = function(knex) {
|
||||||
|
|
||||||
table.string('application');
|
table.string('application');
|
||||||
table.string('application_version');
|
table.string('application_version');
|
||||||
|
table.timestamps(true, true);
|
||||||
|
|
||||||
table.string('player_black');
|
table.string('player_black');
|
||||||
table.string('player_white');
|
table.string('player_white');
|
||||||
|
|
|
@ -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");
|
|
@ -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
|
||||||
|
}
|
Loading…
Reference in a new issue