From 7fe3ebc53f4bdc35991f3058a2e4db70d5f97111 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 16 Apr 2024 07:14:17 +0000 Subject: [PATCH] feat: add index from view columns - WIP --- .../migrations/v2/nc_041_view_column_index.ts | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 packages/nocodb/src/meta/migrations/v2/nc_041_view_column_index.ts diff --git a/packages/nocodb/src/meta/migrations/v2/nc_041_view_column_index.ts b/packages/nocodb/src/meta/migrations/v2/nc_041_view_column_index.ts new file mode 100644 index 0000000000..0668f77279 --- /dev/null +++ b/packages/nocodb/src/meta/migrations/v2/nc_041_view_column_index.ts @@ -0,0 +1,35 @@ +import type { Knex } from 'knex'; +import { MetaTable } from '~/utils/globals'; + +const up = async (knex: Knex) => { + await knex.schema.alterTable(MetaTable.GRID_VIEW_COLUMNS, (table) => { + table.index(['fk_model_id', 'fk_column_id']); + }); + await knex.schema.alterTable(MetaTable.GALLERY_VIEW_COLUMNS, (table) => { + table.index(['fk_model_id', 'fk_column_id']); + }); + await knex.schema.alterTable(MetaTable.KANBAN_VIEW_COLUMNS, (table) => { + table.index(['fk_model_id', 'fk_column_id']); + }); + await knex.schema.alterTable(MetaTable.FORM_VIEW_COLUMNS, (table) => { + table.index(['fk_model_id', 'fk_column_id']); + }); +}; + +const down = async (knex: Knex) => { + + await knex.schema.alterTable(MetaTable.GRID_VIEW_COLUMNS, (table) => { + table.dropIndex(['fk_model_id', 'fk_column_id']); + }); + await knex.schema.alterTable(MetaTable.GALLERY_VIEW_COLUMNS, (table) => { + table.dropIndex(['fk_model_id', 'fk_column_id']); + }); + await knex.schema.alterTable(MetaTable.KANBAN_VIEW_COLUMNS, (table) => { + table.dropIndex(['fk_model_id', 'fk_column_id']); + }); + await knex.schema.alterTable(MetaTable.FORM_VIEW_COLUMNS, (table) => { + table.dropIndex(['fk_model_id', 'fk_column_id']); + }); +}; + +export { up, down };