Browse Source

refactor: remove Count and Autonumber field

- Add upgrader to convert all existing  Count and Autonumber to Number

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4222/head
Pranav C 2 years ago
parent
commit
dc45ca3133
  1. 8
      packages/nc-gui/utils/columnUtils.ts
  2. 2
      packages/nocodb/src/lib/Noco.ts
  3. 2
      packages/nocodb/src/lib/version-upgrader/NcUpgrader.ts
  4. 14
      packages/nocodb/src/lib/version-upgrader/ncDataTypesUpgrader.ts
  5. 1
      packages/nocodb/src/run/docker.ts
  6. 1
      packages/nocodb/src/run/dockerRunMysql.ts
  7. 1
      packages/nocodb/src/run/dockerRunPG.ts
  8. 1
      packages/nocodb/src/run/dockerRunPG_CyQuick.ts

8
packages/nc-gui/utils/columnUtils.ts

@ -122,18 +122,10 @@ const uiTypes = [
icon: MovieRoll,
virtual: 1,
},
{
name: UITypes.Count,
icon: Counter,
},
{
name: UITypes.DateTime,
icon: CalendarClock,
},
{
name: UITypes.AutoNumber,
icon: Numeric,
},
{
name: UITypes.Geometry,
icon: RulerSquareCompass,

2
packages/nocodb/src/lib/Noco.ts

@ -101,7 +101,7 @@ export default class Noco {
constructor() {
process.env.PORT = process.env.PORT || '8080';
// todo: move
process.env.NC_VERSION = '0090000';
process.env.NC_VERSION = '0098004';
// if env variable NC_MINIMAL_DBS is set, then disable project creation with external sources
if (process.env.NC_MINIMAL_DBS) {

2
packages/nocodb/src/lib/version-upgrader/NcUpgrader.ts

@ -5,6 +5,7 @@ import NcMetaIO from '../meta/NcMetaIO';
import ncProjectEnvUpgrader from './ncProjectEnvUpgrader';
import ncProjectEnvUpgrader0011045 from './ncProjectEnvUpgrader0011045';
import ncProjectUpgraderV2_0090000 from './ncProjectUpgraderV2_0090000';
import ncDataTypesUpgrader from './ncDataTypesUpgrader';
const log = debug('nc:version-upgrader');
import { Tele } from 'nc-help';
@ -31,6 +32,7 @@ export default class NcUpgrader {
{ name: '0011043', handler: ncProjectEnvUpgrader },
{ name: '0011045', handler: ncProjectEnvUpgrader0011045 },
{ name: '0090000', handler: ncProjectUpgraderV2_0090000 },
{ name: '0098004', handler: ncDataTypesUpgrader },
];
if (!(await ctx.ncMeta.knexConnection?.schema?.hasTable?.('nc_store'))) {
return;

14
packages/nocodb/src/lib/version-upgrader/ncDataTypesUpgrader.ts

@ -0,0 +1,14 @@
import { UITypes } from 'nocodb-sdk';
import { MetaTable } from '../utils/globals';
import { NcUpgraderCtx } from './NcUpgrader';
// The Count and AutoNumber types are removed
// so convert all existing Count and AutoNumber fields to Number type
export default async function (ctx: NcUpgraderCtx) {
// directly update uidt of all existing Count and AutoNumber fields to Number
await ctx.ncMeta.knex
.update({ uidt: UITypes.Number })
.where({ uidt: UITypes.Count })
.orWhere({ uidt: UITypes.AutoNumber })
.table(MetaTable.COLUMNS);
}

1
packages/nocodb/src/run/docker.ts

@ -2,7 +2,6 @@ import cors from 'cors';
import express from 'express';
import Noco from '../lib/Noco';
process.env.NC_VERSION = '0009044';
const server = express();
server.enable('trust proxy');

1
packages/nocodb/src/run/dockerRunMysql.ts

@ -2,7 +2,6 @@ import cors from 'cors';
import express from 'express';
import Noco from '../lib/Noco';
process.env.NC_VERSION = '0009044';
const server = express();
server.enable('trust proxy');

1
packages/nocodb/src/run/dockerRunPG.ts

@ -2,7 +2,6 @@ import cors from 'cors';
import express from 'express';
import Noco from '../lib/Noco';
process.env.NC_VERSION = '0009044';
const server = express();
server.enable('trust proxy');

1
packages/nocodb/src/run/dockerRunPG_CyQuick.ts

@ -2,7 +2,6 @@ import cors from 'cors';
import express from 'express';
import Noco from '../lib/Noco';
process.env.NC_VERSION = '0009044';
const server = express();
server.enable('trust proxy');

Loading…
Cancel
Save