exports.up = async knex => { await knex.schema.createTable('games', table => { table.uuid('id').primary(); table.index('id'); table.timestamps(true, true); table.binary('data').notNullable(); table.timestamp('upkeep'); table.boolean('finished') .defaultTo(false) .notNullable() .index(); }); await knex.schema.createTable('instances', async table => { table.uuid('id').primary(); table.index('id'); table.timestamps(true, true); table.binary('data').notNullable(); table.boolean('open') .defaultTo(false) .notNullable() .index(); table.boolean('finished') .defaultTo(false) .notNullable() .index(); table.timestamp('upkeep'); }); await knex.schema.createTable('players', table => { table.uuid('id').primary(); table.index('id'); table.timestamps(true, true); // the instance table.uuid('instance').notNullable() table.foreign('instance') .references('id') .inTable('instances') .onDelete('CASCADE'); table.index('instance'); // account in a game table.uuid('account').notNullable() table.foreign('account') .references('id') .inTable('accounts') .onDelete('CASCADE'); table.index('account'); table.unique(['account', 'instance']); }); await knex.schema.createTable('matchmaking', async table => { table.uuid('id').primary(); table.index('id'); table.timestamps(true, true); table.uuid('game').notNullable() table.foreign('game') .references('id') .inTable('games') .onDelete('NO ACTION'); }); }; exports.down = async () => {};