add message table with migration
This commit is contained in:
parent
a10453a848
commit
5205035d7c
3 changed files with 27 additions and 0 deletions
|
@ -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');
|
||||
|
|
13
server/data/migrations/20200120232142_message.js
Normal file
13
server/data/migrations/20200120232142_message.js
Normal 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");
|
13
server/data/queries/message.js
Normal file
13
server/data/queries/message.js
Normal 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
|
||||
}
|
Loading…
Reference in a new issue