Browse Source

refactor(nocodb): rename grp_column_id to fk_grp_col_id

pull/4001/head
Wing-Kam Wong 2 years ago
parent
commit
34e0e34c8a
  1. 4
      packages/nocodb/src/lib/migrations/XcMigrationSourcev2.ts
  2. 41
      packages/nocodb/src/lib/migrations/v2/nc_021_rename_kanban_grp_col_id.ts
  3. 6
      packages/nocodb/src/lib/models/KanbanView.ts
  4. 6
      packages/nocodb/src/lib/models/View.ts

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

@ -8,6 +8,7 @@ import * as nc_017_add_user_token_version_column from './v2/nc_017_add_user_toke
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_add_kanban_meta_col from './v2/nc_020_add_kanban_meta_col';
import * as nc_021_rename_kanban_grp_col_id from './v2/nc_021_rename_kanban_grp_col_id';
// Create a custom migration source class // Create a custom migration source class
export default class XcMigrationSourcev2 { export default class XcMigrationSourcev2 {
@ -27,6 +28,7 @@ export default class XcMigrationSourcev2 {
'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_add_kanban_meta_col',
'nc_021_rename_kanban_grp_col_id',
]); ]);
} }
@ -56,6 +58,8 @@ export default class XcMigrationSourcev2 {
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_add_kanban_meta_col':
return nc_020_add_kanban_meta_col; return nc_020_add_kanban_meta_col;
case 'nc_021_rename_kanban_grp_col_id':
return nc_021_rename_kanban_grp_col_id;
} }
} }
} }

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

@ -0,0 +1,41 @@
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/>.
*
*/

6
packages/nocodb/src/lib/models/KanbanView.ts

@ -9,7 +9,7 @@ export default class KanbanView implements KanbanType {
title: string; title: string;
project_id?: string; project_id?: string;
base_id?: string; base_id?: string;
grp_column_id?: string; fk_grp_col_id?: string;
meta?: string | object; meta?: string | object;
// below fields are not in use at this moment // below fields are not in use at this moment
@ -50,7 +50,7 @@ export default class KanbanView implements KanbanType {
( (
await ncMeta.metaList2(null, null, MetaTable.KANBAN_VIEW, { await ncMeta.metaList2(null, null, MetaTable.KANBAN_VIEW, {
condition: { condition: {
grp_column_id: columnId, fk_grp_col_id: columnId,
}, },
}) })
).length > 0 ).length > 0
@ -62,7 +62,7 @@ export default class KanbanView implements KanbanType {
project_id: view.project_id, project_id: view.project_id,
base_id: view.base_id, base_id: view.base_id,
fk_view_id: view.fk_view_id, fk_view_id: view.fk_view_id,
grp_column_id: view.grp_column_id, fk_grp_col_id: view.fk_grp_col_id,
meta: view.meta, meta: view.meta,
}; };

6
packages/nocodb/src/lib/models/View.ts

@ -225,7 +225,7 @@ export default class View implements ViewType {
view: Partial<View> & view: Partial<View> &
Partial<FormView | GridView | GalleryView | KanbanView> & { Partial<FormView | GridView | GalleryView | KanbanView> & {
copy_from_id?: string; copy_from_id?: string;
grp_column_id?: string; fk_grp_col_id?: string;
created_at?; created_at?;
updated_at?; updated_at?;
}, },
@ -312,7 +312,7 @@ export default class View implements ViewType {
break; break;
case ViewTypes.KANBAN: case ViewTypes.KANBAN:
// set grouping field // set grouping field
(view as KanbanView).grp_column_id = view.grp_column_id; (view as KanbanView).fk_grp_col_id = view.fk_grp_col_id;
await KanbanView.insert( await KanbanView.insert(
{ {
@ -398,7 +398,7 @@ export default class View implements ViewType {
} }
} else if (view.type === ViewTypes.KANBAN && !copyFromView) { } else if (view.type === ViewTypes.KANBAN && !copyFromView) {
const kanbanView = await KanbanView.get(view_id, ncMeta); const kanbanView = await KanbanView.get(view_id, ncMeta);
if (vCol.id === kanbanView?.grp_column_id) { if (vCol.id === kanbanView?.fk_grp_col_id) {
// include grouping field if it exists // include grouping field if it exists
show = true; show = true;
} else if (vCol.pv) { } else if (vCol.pv) {

Loading…
Cancel
Save