π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
fix: migrations
Ramesh Maned1a2d5cc5163
diff --git a/packages/nocodb/src/meta/migrations/XcMigrationSourcev0.ts b/packages/nocodb/src/meta/migrations/XcMigrationSourcev0.tsindex 2225c16945..8d65e546d4 100644--- a/packages/nocodb/src/meta/migrations/XcMigrationSourcev0.ts+++ b/packages/nocodb/src/meta/migrations/XcMigrationSourcev0.ts@@ -25,6 +25,7 @@ import * as nc_202601010000_placeholder from './v0/nc_202601010000_placeholder';import * as nc_202602250000_outline_view from './v0/nc_202602250000_outline_view';import * as nc_202602250001_button_filter from './v0/nc_202602250001_button_filter';import * as nc_202602260000_rename_outline_to_list_view from './v0/nc_202602260000_rename_outline_to_list_view';+import * as nc_202602260636_view_sections from './v0/nc_202602260636_view_sections';// Create a custom migration source classexport default class XcMigrationSourcev0 {@@ -61,6 +62,7 @@ export default class XcMigrationSourcev0 {'nc_202602250000_outline_view','nc_202602250001_button_filter','nc_202602260000_rename_outline_to_list_view',+ 'nc_202602260636_view_sections',]);}@@ -124,6 +126,8 @@ export default class XcMigrationSourcev0 {return nc_202602250001_button_filter;case 'nc_202602260000_rename_outline_to_list_view':return nc_202602260000_rename_outline_to_list_view;+ case 'nc_202602260636_view_sections':+ return nc_202602260636_view_sections;}}}diff --git a/packages/nocodb/src/meta/migrations/XcMigrationSourcev2.ts b/packages/nocodb/src/meta/migrations/XcMigrationSourcev2.tsindex 82da7dc409..2b622ae35d 100644--- a/packages/nocodb/src/meta/migrations/XcMigrationSourcev2.ts+++ b/packages/nocodb/src/meta/migrations/XcMigrationSourcev2.ts@@ -86,7 +86,6 @@ import * as nc_094_add_meta_to_filter_exp_v2 from '~/meta/migrations/v2/nc_094_aimport * as nc_096_deprecate_unused from '~/meta/migrations/v2/nc_096_deprecate_unused';import * as nc_097_unify_schema from '~/meta/migrations/v2/nc_097_unify_schema';import * as nc_098_default_workspace from '~/meta/migrations/v2/nc_098_default_workspace';-import * as nc_099_view_sections from '~/meta/migrations/v2/nc_099_view_sections';// Create a custom migration source classexport default class XcMigrationSourcev2 {@@ -182,7 +181,6 @@ export default class XcMigrationSourcev2 {'nc_096_deprecate_unused','nc_097_unify_schema','nc_098_default_workspace',- 'nc_099_view_sections',]);}@@ -364,8 +362,6 @@ export default class XcMigrationSourcev2 {return nc_097_unify_schema;case 'nc_098_default_workspace':return nc_098_default_workspace;- case 'nc_099_view_sections':- return nc_099_view_sections;}}}diff --git a/packages/nocodb/src/meta/migrations/v0/nc_001_init.ts b/packages/nocodb/src/meta/migrations/v0/nc_001_init.tsindex 6d5cc08a47..5f30d2a243 100644--- a/packages/nocodb/src/meta/migrations/v0/nc_001_init.ts+++ b/packages/nocodb/src/meta/migrations/v0/nc_001_init.ts@@ -1270,26 +1270,6 @@ const up = async (knex: Knex) => {table.timestamps(true, true);});- await knex.schema.createTable(MetaTable.VIEW_SECTIONS, (table) => {- table.string('id', 20).notNullable();-- table.string('fk_workspace_id', 20);- table.string('base_id', 20);- table.string('source_id', 20);-- table.string('fk_model_id', 20).notNullable();- table.string('title', 255).notNullable();- table.float('order');- table.text('meta');-- table.string('created_by', 20);- table.string('updated_by', 20);-- table.timestamps(true, true);-- table.primary(['base_id', 'id']);- });-await knex.schema.createTable(MetaTable.VIEWS, (table) => {table.string('id', 20).notNullable();table.string('source_id', 20);@@ -1313,7 +1293,6 @@ const up = async (knex: Knex) => {table.string('expanded_record_mode', 255);table.string('fk_custom_url_id', 20);table.string('row_coloring_mode', 10);- table.string('fk_view_section_id', 20);table.timestamps(true, true);table.primary(['base_id', 'id']);});@@ -1464,15 +1443,6 @@ const up = async (knex: Knex) => {table.index(['id'], 'nc_widgets_v2_oldpk_idx');});- await knex.schema.alterTable(MetaTable.VIEW_SECTIONS, (table) => {- table.index(- ['base_id', 'fk_workspace_id'],- 'nc_view_sections_context',- );- table.index('fk_model_id', 'nc_view_sections_model_idx');- table.index(['id'], 'nc_view_sections_v2_oldpk_idx');- });-await knex.schema.alterTable(MetaTable.PERMISSIONS, (table) => {table.index(['base_id', 'fk_workspace_id'], 'nc_permissions_context');table.index(['entity', 'entity_id', 'permission'], 'nc_permissions_entity');@@ -2168,7 +2138,6 @@ const down = async (knex: Knex) => {await knex.schema.dropTableIfExists(MetaTable.WORKSPACE_USER);await knex.schema.dropTableIfExists(MetaTable.WORKSPACE);await knex.schema.dropTableIfExists(MetaTable.NOTIFICATION);- await knex.schema.dropTableIfExists(MetaTable.VIEW_SECTIONS);await knex.schema.dropTableIfExists(MetaTable.VIEWS);await knex.schema.dropTableIfExists(MetaTable.USERS);await knex.schema.dropTableIfExists(MetaTable.USER_REFRESH_TOKENS);diff --git a/packages/nocodb/src/meta/migrations/v0/nc_202602260636_view_sections.ts b/packages/nocodb/src/meta/migrations/v0/nc_202602260636_view_sections.tsnew file mode 100644index 0000000000..49fa09df74--- /dev/null+++ b/packages/nocodb/src/meta/migrations/v0/nc_202602260636_view_sections.ts@@ -0,0 +1,54 @@+import type { Knex } from 'knex';+import { MetaTable } from '~/utils/globals';++const up = async (knex: Knex) => {+ const hasTable = await knex.schema.hasTable(MetaTable.VIEW_SECTIONS);+ if (!hasTable) {+ await knex.schema.createTable(MetaTable.VIEW_SECTIONS, (table) => {+ table.string('id', 20).primary().notNullable();++ table.string('fk_workspace_id', 20);+ table.string('base_id', 20);+ table.string('source_id', 20);+ table.string('fk_model_id', 20).notNullable();++ table.string('title', 255).notNullable();+ table.float('order');+ table.text('meta');++ table.string('created_by', 20);+ table.string('updated_by', 20);++ table.timestamps(true, true);++ table.index(['base_id', 'fk_workspace_id'], 'nc_view_sections_context');+ table.index('fk_model_id', 'nc_view_sections_model_idx');+ });+ }++ const hasColumn = await knex.schema.hasColumn(+ MetaTable.VIEWS,+ 'fk_view_section_id',+ );+ if (!hasColumn) {+ await knex.schema.alterTable(MetaTable.VIEWS, (table) => {+ table.string('fk_view_section_id', 20).nullable();+ });+ }+};++const down = async (knex: Knex) => {+ await knex.schema.dropTableIfExists(MetaTable.VIEW_SECTIONS);++ const hasColumn = await knex.schema.hasColumn(+ MetaTable.VIEWS,+ 'fk_view_section_id',+ );+ if (hasColumn) {+ await knex.schema.alterTable(MetaTable.VIEWS, (table) => {+ table.dropColumn('fk_view_section_id');+ });+ }+};++export { up, down };diff --git a/packages/nocodb/src/meta/migrations/v2/nc_099_view_sections.ts b/packages/nocodb/src/meta/migrations/v2/nc_099_view_sections.tsdeleted file mode 100644index 7f5fd27a1c..0000000000--- a/packages/nocodb/src/meta/migrations/v2/nc_099_view_sections.ts+++ /dev/null@@ -1,43 +0,0 @@-import type { Knex } from 'knex';-import { MetaTable } from '~/utils/globals';--const up = async (knex: Knex) => {- await knex.schema.createTable(MetaTable.VIEW_SECTIONS, (table) => {- table.string('id', 20).primary().notNullable();-- table.string('fk_workspace_id', 20);- table.string('base_id', 20);- table.string('source_id', 20);- table.string('fk_model_id', 20).notNullable();-- table.string('title', 255).notNullable();- table.float('order');- table.text('meta');-- table.string('created_by', 20);- table.string('updated_by', 20);-- table.timestamps(true, true);-- table.index(['base_id', 'fk_workspace_id'], 'nc_view_sections_context');- table.index('fk_model_id', 'nc_view_sections_model_idx');- });-- if (!(await knex.schema.hasColumn(MetaTable.VIEWS, 'fk_view_section_id'))) {- await knex.schema.alterTable(MetaTable.VIEWS, (table) => {- table.string('fk_view_section_id', 20).nullable();- });- }-};--const down = async (knex: Knex) => {- await knex.schema.dropTableIfExists(MetaTable.VIEW_SECTIONS);-- if (await knex.schema.hasColumn(MetaTable.VIEWS, 'fk_view_section_id')) {- await knex.schema.alterTable(MetaTable.VIEWS, (table) => {- table.dropColumn('fk_view_section_id');- });- }-};--export { up, down };