36 lines
923 B
JavaScript
36 lines
923 B
JavaScript
exports.up = async knex => {
|
|
await knex.schema.createTable('games', table => {
|
|
table.uuid('id').primary();
|
|
table.index('id');
|
|
table.timestamps();
|
|
|
|
table.binary('data').notNullable();
|
|
table.boolean('joinable')
|
|
.defaultTo(true)
|
|
.notNullable();
|
|
});
|
|
|
|
await knex.schema.createTable('players', table => {
|
|
table.uuid('id').primary();
|
|
table.index('id');
|
|
|
|
// the game itself
|
|
table.uuid('game').notNullable()
|
|
table.foreign('game')
|
|
.references('id')
|
|
.inTable('games')
|
|
.onDelete('CASCADE');
|
|
table.index('game');
|
|
|
|
// account in a game
|
|
table.uuid('account').notNullable()
|
|
table.foreign('account')
|
|
.references('id')
|
|
.inTable('accounts')
|
|
.onDelete('CASCADE');
|
|
table.index('account');
|
|
|
|
});
|
|
};
|
|
|
|
exports.down = async () => {}; |