From d3f90f37005cb71fc0ef2c0cffe3c23d6faa9ce4 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 16 Apr 2024 07:14:18 +0000 Subject: [PATCH] fix: migration corrections --- .../meta/migrations/XcMigrationSourcev2.ts | 4 +++ ...n_index.ts => nc_042_view_column_index.ts} | 29 ++++++++++++------- 2 files changed, 23 insertions(+), 10 deletions(-) rename packages/nocodb/src/meta/migrations/v2/{nc_041_view_column_index.ts => nc_042_view_column_index.ts} (64%) diff --git a/packages/nocodb/src/meta/migrations/XcMigrationSourcev2.ts b/packages/nocodb/src/meta/migrations/XcMigrationSourcev2.ts index 8702674989..4a0aa82533 100644 --- a/packages/nocodb/src/meta/migrations/XcMigrationSourcev2.ts +++ b/packages/nocodb/src/meta/migrations/XcMigrationSourcev2.ts @@ -30,6 +30,7 @@ import * as nc_040_form_view_alter_column_types from '~/meta/migrations/v2/nc_04 import * as nc_041_calendar_view from '~/meta/migrations/v2/nc_041_calendar_view'; import * as nc_042_user_block from '~/meta/migrations/v2/nc_042_user_block'; import * as nc_043_user_refresh_token from '~/meta/migrations/v2/nc_043_user_refresh_token'; +import * as nc_042_view_column_index from '~/meta/migrations/v2/nc_042_view_column_index'; // Create a custom migration source class export default class XcMigrationSourcev2 { @@ -71,6 +72,7 @@ export default class XcMigrationSourcev2 { 'nc_041_calendar_view', 'nc_042_user_block', 'nc_043_user_refresh_token', + 'nc_042_view_column_index', ]); } @@ -144,6 +146,8 @@ export default class XcMigrationSourcev2 { return nc_042_user_block; case 'nc_043_user_refresh_token': return nc_043_user_refresh_token; + case 'nc_042_view_column_index': + return nc_042_view_column_index; } } } diff --git a/packages/nocodb/src/meta/migrations/v2/nc_041_view_column_index.ts b/packages/nocodb/src/meta/migrations/v2/nc_042_view_column_index.ts similarity index 64% rename from packages/nocodb/src/meta/migrations/v2/nc_041_view_column_index.ts rename to packages/nocodb/src/meta/migrations/v2/nc_042_view_column_index.ts index 7833d87101..55ed372ecc 100644 --- a/packages/nocodb/src/meta/migrations/v2/nc_041_view_column_index.ts +++ b/packages/nocodb/src/meta/migrations/v2/nc_042_view_column_index.ts @@ -5,50 +5,59 @@ const up = async (knex: Knex) => { console.log('Adding index to view column tables...'); console.time('Added index to Grid view columns'); await knex.schema.alterTable(MetaTable.GRID_VIEW_COLUMNS, (table) => { - table.index(['fk_model_id', 'fk_column_id']); + table.index(['fk_view_id', 'fk_column_id']); }); console.timeEnd('Added index to Grid view columns'); console.time('Added index to Gallery view columns'); await knex.schema.alterTable(MetaTable.GALLERY_VIEW_COLUMNS, (table) => { - table.index(['fk_model_id', 'fk_column_id']); + table.index(['fk_view_id', 'fk_column_id']); }); console.timeEnd('Added index to Gallery view columns'); console.time('Added index to Kanban view columns'); await knex.schema.alterTable(MetaTable.KANBAN_VIEW_COLUMNS, (table) => { - table.index(['fk_model_id', 'fk_column_id']); + table.index(['fk_view_id', 'fk_column_id']); }); console.timeEnd('Added index to Kanban view columns'); console.time('Added index to Form view columns'); await knex.schema.alterTable(MetaTable.FORM_VIEW_COLUMNS, (table) => { - table.index(['fk_model_id', 'fk_column_id']); + table.index(['fk_view_id', 'fk_column_id']); }); console.timeEnd('Added index to Form view columns'); console.time('Added index to Calendar view columns'); await knex.schema.alterTable(MetaTable.CALENDAR_VIEW_COLUMNS, (table) => { - table.index(['fk_model_id', 'fk_column_id']); + table.index(['fk_view_id', 'fk_column_id']); }); console.timeEnd('Added index to Calendar view columns'); + + console.time('Added index to Map view columns'); + await knex.schema.alterTable(MetaTable.MAP_VIEW_COLUMNS, (table) => { + table.index(['fk_view_id', 'fk_column_id']); + }); + console.timeEnd('Added index to Map view columns'); }; const down = async (knex: Knex) => { await knex.schema.alterTable(MetaTable.GRID_VIEW_COLUMNS, (table) => { - table.dropIndex(['fk_model_id', 'fk_column_id']); + table.dropIndex(['fk_view_id', 'fk_column_id']); }); await knex.schema.alterTable(MetaTable.GALLERY_VIEW_COLUMNS, (table) => { - table.dropIndex(['fk_model_id', 'fk_column_id']); + table.dropIndex(['fk_view_id', 'fk_column_id']); }); await knex.schema.alterTable(MetaTable.KANBAN_VIEW_COLUMNS, (table) => { - table.dropIndex(['fk_model_id', 'fk_column_id']); + table.dropIndex(['fk_view_id', 'fk_column_id']); }); await knex.schema.alterTable(MetaTable.FORM_VIEW_COLUMNS, (table) => { - table.dropIndex(['fk_model_id', 'fk_column_id']); + table.dropIndex(['fk_view_id', 'fk_column_id']); }); await knex.schema.alterTable(MetaTable.CALENDAR_VIEW_COLUMNS, (table) => { - table.dropIndex(['fk_model_id', 'fk_column_id']); + table.dropIndex(['fk_view_id', 'fk_column_id']); + }); + await knex.schema.alterTable(MetaTable.MAP_VIEW_COLUMNS, (table) => { + table.dropIndex(['fk_view_id', 'fk_column_id']); }); };