mnml/ops/migrations/20181020104420_games.js
2018-10-20 17:06:44 +11:00

41 lines
1.0 KiB
JavaScript

exports.up = async knex => {
await knex.schema.createTable('games', table => {
table.uuid('id').primary();
table.index('id');
table.timestamps();
table.binary('data').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');
// cryp in a game
table.uuid('cryp').notNullable()
table.foreign('cryp')
.references('id')
.inTable('cryps')
.onDelete('CASCADE');
table.index('cryp');
// account in a game
table.uuid('account').notNullable()
table.foreign('account')
.references('id')
.inTable('accounts')
.onDelete('CASCADE');
table.index('account');
});
};
exports.down = async () => {};