diff --git a/packages/lib-db/src/migrations/sql/20241030130613-index-for-roleId.ts b/packages/lib-db/src/migrations/sql/20241030130613-index-for-roleId.ts new file mode 100644 index 0000000000..0214822e44 --- /dev/null +++ b/packages/lib-db/src/migrations/sql/20241030130613-index-for-roleId.ts @@ -0,0 +1,31 @@ +import { Knex } from 'knex'; + +export async function up(knex: Knex): Promise { + await knex.schema.alterTable('permissionOnRole', (table) => { + table.index(['roleId']); + }); + + await knex.schema.alterTable('playerOnGameServer', (table) => { + table.index(['domain', 'playerId']); + }); + + await knex.schema.alterTable('playerInventory', (table) => { + table.dropIndex(['playerId', 'domain']); + table.index(['playerId', 'domain', 'itemId']); + }); +} + +export async function down(knex: Knex): Promise { + await knex.schema.alterTable('permissionOnRole', (table) => { + table.dropIndex(['roleId']); + }); + + await knex.schema.alterTable('playerOnGameServer', (table) => { + table.dropIndex(['domain', 'playerId']); + }); + + await knex.schema.alterTable('playerInventory', (table) => { + table.dropIndex(['playerId', 'domain', 'itemId']); + table.index(['playerId', 'domain']); + }); +}