Browse Source

fix: add alter column dt scripts (#1740)

* fix: add alter column dt scripts

Signed-off-by: Wing-Kam Wong <wingkwong.code@gmail.com>

* refactor: move migration to v2 migrations, modify `dtxp` column, and ignore migration for sqlite

Signed-off-by: Pranav C <pranavxc@gmail.com>

Co-authored-by: Pranav C <pranavxc@gmail.com>
pull/1746/head
աɨռɢӄաօռɢ 3 years ago committed by GitHub
parent
commit
b9250af058
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      packages/nocodb/package.json
  2. 7
      packages/nocodb/src/lib/noco/common/XcMigrationSourcev2.ts
  3. 0
      packages/nocodb/src/lib/noco/migrationsv2/nc_011.ts
  4. 48
      packages/nocodb/src/lib/noco/migrationsv2/nc_012_alter_column_data_types.ts

2
packages/nocodb/package.json

@ -67,7 +67,7 @@
"help:c": "ts-node ./help/a",
"watch:build": "nodemon -e ts,js -w ./src -x npm run build",
"watch:serve": "nodemon -e ts -w ./build -x npm run debug-local ",
"watch:run": "cross-env NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/example/docker --log-error --project tsconfig.json\"",
"watch:run": "cross-env NC_DISABLE_TELE1=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/example/docker --log-error --project tsconfig.json\"",
"watch:run:cypress": "cross-env EE=true nodemon -e ts,js -w ./src -x \"ts-node src/example/docker --log-error --project tsconfig.json\"",
"watch:run:mysql": "cross-env NC_DISABLE_TELE=true EE=true nodemon -e ts,js -w ./src -x \"ts-node src/example/dockerRunMysql --log-error --project tsconfig.json\"",
"run": "ts-node src/example/docker",

7
packages/nocodb/src/lib/noco/common/XcMigrationSourcev2.ts

@ -1,4 +1,5 @@
import * as nc_011 from '../migrations/nc_011';
import * as nc_011 from '../migrationsv2/nc_011';
import * as nc_012_alter_column_data_types from '../migrationsv2/nc_012_alter_column_data_types';
// Create a custom migration source class
export default class XcMigrationSourcev2 {
@ -7,7 +8,7 @@ export default class XcMigrationSourcev2 {
// arguments to getMigrationName and getMigration
public getMigrations(): Promise<any> {
// In this example we are just returning migration names
return Promise.resolve(['nc_011']);
return Promise.resolve(['nc_011', 'nc_012_alter_column_data_types']);
}
public getMigrationName(migration): string {
@ -18,6 +19,8 @@ export default class XcMigrationSourcev2 {
switch (migration) {
case 'nc_011':
return nc_011;
case 'nc_012_alter_column_data_types':
return nc_012_alter_column_data_types;
}
}
}

0
packages/nocodb/src/lib/noco/migrations/nc_011.ts → packages/nocodb/src/lib/noco/migrationsv2/nc_011.ts

48
packages/nocodb/src/lib/noco/migrationsv2/nc_012_alter_column_data_types.ts

@ -0,0 +1,48 @@
import Knex from 'knex';
import { MetaTable } from '../../utils/globals';
const up = async (knex: Knex) => {
if (knex.client.config.client !== 'sqlite3') {
await knex.schema.alterTable(MetaTable.COLUMNS, table => {
table.text('cdf').alter();
table.text('dtxp').alter();
table.text('cc').alter();
table.text('ct').alter();
});
}
};
const down = async knex => {
await knex.schema.alterTable(MetaTable.COLUMNS, table => {
if (knex.client.config.client !== 'sqlite3') {
table.string('cdf').alter();
table.string('dtxp').alter();
table.string('cc').alter();
table.string('ct').alter();
}
});
};
export { up, down };
/**
* @copyright Copyright (c) 2022, 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