Browse Source

fix: migration corrections

pull/8281/head
Pranav C 7 months ago
parent
commit
d3f90f3700
  1. 4
      packages/nocodb/src/meta/migrations/XcMigrationSourcev2.ts
  2. 29
      packages/nocodb/src/meta/migrations/v2/nc_042_view_column_index.ts

4
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;
}
}
}

29
packages/nocodb/src/meta/migrations/v2/nc_041_view_column_index.ts → 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']);
});
};
Loading…
Cancel
Save