From ab5ad7ecc3d13abf2552e2a7648a81aef314c0fe Mon Sep 17 00:00:00 2001 From: Johan Haals Date: Mon, 19 Apr 2021 11:52:12 +0200 Subject: [PATCH] Create missing indexes, cleanup in down MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fredrik Adelöw Signed-off-by: Johan Haals --- .../20210302150147_refresh_state.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/plugins/catalog-backend/migrationsv2/20210302150147_refresh_state.js b/plugins/catalog-backend/migrationsv2/20210302150147_refresh_state.js index 56c594ddf2..6abab6270b 100644 --- a/plugins/catalog-backend/migrationsv2/20210302150147_refresh_state.js +++ b/plugins/catalog-backend/migrationsv2/20210302150147_refresh_state.js @@ -86,6 +86,7 @@ exports.up = async function up(knex) { ); table.text('etag').notNullable().comment('Etag to be used for caching'); table.text('finalized_entity').notNullable().comment('The final entity'); + table.index('entity_id', 'final_entities_entity_id_idx'); }); await knex.schema.createTable('refresh_state_references', table => { @@ -149,11 +150,8 @@ exports.up = async function up(knex) { .text('target_entity_ref') .notNullable() .comment('The entity reference of the target entity of the relation'); - - table.index( - ['source_entity_ref', 'type', 'target_entity_ref'], - 'relations_full_ref_idx', - ); + table.index('source_entity_ref', 'relations_source_entity_ref_idx'); + table.index('originating_entity_id', 'relations_source_entity_id_idx'); }); }; @@ -170,6 +168,15 @@ exports.down = async function down(knex) { table.dropIndex([], 'refresh_state_entity_ref_idx'); table.dropIndex([], 'refresh_state_next_update_at_idx'); }); - await knex.schema.dropTable('refresh_state'); + await knex.schema.alterTable('final_entities', table => { + table.dropIndex([], 'final_entities_entity_id_idx'); + }); + await knex.schema.alterTable('relations', table => { + table.index('source_entity_ref', 'relations_source_entity_ref_idx'); + table.index('originating_entity_id', 'relations_source_entity_id_idx'); + }); + await knex.schema.dropTable('final_entities'); + await knex.schema.dropTable('relations'); await knex.schema.dropTable('references'); + await knex.schema.dropTable('refresh_state'); };