Browse Source

Merge pull request #4008 from nocodb/refactor/kanban-migration-scripts

refactor(nocodb): combine all kanban migration into one
pull/4039/head
աɨռɢӄաօռɢ 2 years ago committed by GitHub
parent
commit
7f689c9f73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      packages/nocodb/src/lib/migrations/XcMigrationSourcev2.ts
  2. 40
      packages/nocodb/src/lib/migrations/v2/nc_020_add_kanban_meta_col.ts
  3. 9
      packages/nocodb/src/lib/migrations/v2/nc_020_kanban_view.ts
  4. 41
      packages/nocodb/src/lib/migrations/v2/nc_021_rename_kanban_grp_col_id.ts

16
packages/nocodb/src/lib/migrations/XcMigrationSourcev2.ts

@ -7,9 +7,7 @@ import * as nc_016_alter_hooklog_payload_types from './v2/nc_016_alter_hooklog_p
import * as nc_017_add_user_token_version_column from './v2/nc_017_add_user_token_version_column'; import * as nc_017_add_user_token_version_column from './v2/nc_017_add_user_token_version_column';
import * as nc_018_add_meta_in_view from './v2/nc_018_add_meta_in_view'; import * as nc_018_add_meta_in_view from './v2/nc_018_add_meta_in_view';
import * as nc_019_add_meta_in_meta_tables from './v2/nc_019_add_meta_in_meta_tables'; import * as nc_019_add_meta_in_meta_tables from './v2/nc_019_add_meta_in_meta_tables';
import * as nc_020_add_kanban_meta_col from './v2/nc_020_add_kanban_meta_col'; import * as nc_020_kanban_view from './v2/nc_020_kanban_view';
import * as nc_021_rename_kanban_grp_col_id from './v2/nc_021_rename_kanban_grp_col_id';
import * as nc_022_add_kanban_fk_cover_image_col_id from './v2/nc_022_add_kanban_fk_cover_image_col_id';
// Create a custom migration source class // Create a custom migration source class
export default class XcMigrationSourcev2 { export default class XcMigrationSourcev2 {
@ -28,9 +26,7 @@ export default class XcMigrationSourcev2 {
'nc_017_add_user_token_version_column', 'nc_017_add_user_token_version_column',
'nc_018_add_meta_in_view', 'nc_018_add_meta_in_view',
'nc_019_add_meta_in_meta_tables', 'nc_019_add_meta_in_meta_tables',
'nc_020_add_kanban_meta_col', 'nc_020_kanban_view',
'nc_021_rename_kanban_grp_col_id',
'nc_022_add_kanban_fk_cover_image_col_id'
]); ]);
} }
@ -58,12 +54,8 @@ export default class XcMigrationSourcev2 {
return nc_018_add_meta_in_view; return nc_018_add_meta_in_view;
case 'nc_019_add_meta_in_meta_tables': case 'nc_019_add_meta_in_meta_tables':
return nc_019_add_meta_in_meta_tables; return nc_019_add_meta_in_meta_tables;
case 'nc_020_add_kanban_meta_col': case 'nc_020_kanban_view':
return nc_020_add_kanban_meta_col; return nc_020_kanban_view;
case 'nc_021_rename_kanban_grp_col_id':
return nc_021_rename_kanban_grp_col_id;
case 'nc_022_add_kanban_fk_cover_image_col_id':
return nc_022_add_kanban_fk_cover_image_col_id;
} }
} }
} }

40
packages/nocodb/src/lib/migrations/v2/nc_020_add_kanban_meta_col.ts

@ -1,40 +0,0 @@
import Knex from 'knex';
import { MetaTable } from '../../utils/globals';
const up = async (knex: Knex) => {
await knex.schema.alterTable(MetaTable.KANBAN_VIEW, (table) => {
table.string('grp_column_id');
table.text('meta');
});
};
const down = async (knex) => {
await knex.schema.alterTable(MetaTable.KANBAN_VIEW, (table) => {
table.dropColumns('grp_column_id');
table.dropColumns('meta');
});
};
export { up, down };
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Wing-Kam Wong <wingkwong.code@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

9
packages/nocodb/src/lib/migrations/v2/nc_022_add_kanban_fk_cover_image_col_id.ts → packages/nocodb/src/lib/migrations/v2/nc_020_kanban_view.ts

@ -3,15 +3,24 @@ import { MetaTable } from '../../utils/globals';
const up = async (knex: Knex) => { const up = async (knex: Knex) => {
await knex.schema.alterTable(MetaTable.KANBAN_VIEW, (table) => { await knex.schema.alterTable(MetaTable.KANBAN_VIEW, (table) => {
table.string('fk_grp_col_id', 20);
table
.foreign('fk_grp_col_id')
.references(`${MetaTable.COLUMNS}.id`);
table.string('fk_cover_image_col_id', 20); table.string('fk_cover_image_col_id', 20);
table table
.foreign('fk_cover_image_col_id') .foreign('fk_cover_image_col_id')
.references(`${MetaTable.COLUMNS}.id`); .references(`${MetaTable.COLUMNS}.id`);
table.text('meta');
}); });
}; };
const down = async (knex) => { const down = async (knex) => {
await knex.schema.alterTable(MetaTable.KANBAN_VIEW, (table) => { await knex.schema.alterTable(MetaTable.KANBAN_VIEW, (table) => {
table.dropColumns('meta');
table.dropColumns('fk_grp_col_id');
table.dropColumns('fk_cover_image_col_id'); table.dropColumns('fk_cover_image_col_id');
}); });
}; };

41
packages/nocodb/src/lib/migrations/v2/nc_021_rename_kanban_grp_col_id.ts

@ -1,41 +0,0 @@
import Knex from 'knex';
import { MetaTable } from '../../utils/globals';
const up = async (knex: Knex) => {
await knex.schema.alterTable(MetaTable.KANBAN_VIEW, (table) => {
table.renameColumn('grp_column_id', 'fk_grp_col_id')
table
.foreign('fk_grp_col_id')
.references(`${MetaTable.COLUMNS}.id`);
});
};
const down = async (knex) => {
await knex.schema.alterTable(MetaTable.KANBAN_VIEW, (table) => {
table.dropColumns('fk_grp_col_id');
});
};
export { up, down };
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Wing-Kam Wong <wingkwong.code@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
Loading…
Cancel
Save