Browse Source

refactor(nocodb): remove created_at & updated_at

pull/5222/head
Wing-Kam Wong 2 years ago
parent
commit
045660a9c2
  1. 8
      packages/nocodb/src/lib/models/Base.ts
  2. 6
      packages/nocodb/src/lib/models/Model.ts
  3. 4
      packages/nocodb/src/lib/models/ProjectUser.ts
  4. 35
      packages/nocodb/src/lib/version-upgrader/ncProjectUpgraderV2_0090000.ts
  5. 88
      packages/nocodb/src/schema/swagger.json

8
packages/nocodb/src/lib/models/Base.ts

@ -32,8 +32,6 @@ export default class Base implements BaseType {
type?: typeof DB_TYPES[number];
is_meta?: BoolType;
config?: string;
created_at?: string;
updated_at?: string;
inflection_column?: string;
inflection_table?: string;
order?: number;
@ -53,8 +51,6 @@ export default class Base implements BaseType {
'config',
'type',
'is_meta',
'created_at',
'updated_at',
'inflection_column',
'inflection_table',
'order',
@ -91,8 +87,6 @@ export default class Base implements BaseType {
base: BaseType & {
id: string;
projectId: string;
created_at?;
updated_at?;
},
ncMeta = Noco.ncMeta
) {
@ -111,8 +105,6 @@ export default class Base implements BaseType {
'config',
'type',
'is_meta',
'created_at',
'updated_at',
'inflection_column',
'inflection_table',
'order',

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

@ -100,8 +100,6 @@ export default class Model implements TableType {
baseId,
model: Partial<TableReqType> & {
mm?: BoolType;
created_at?: any;
updated_at?: any;
type?: ModelTypes;
},
ncMeta = Noco.ncMeta
@ -112,8 +110,6 @@ export default class Model implements TableType {
'mm',
'order',
'type',
'created_at',
'updated_at',
'id',
]);
@ -152,8 +148,6 @@ export default class Model implements TableType {
title: model.title || model.table_name,
is_default: true,
type: ViewTypes.GRID,
created_at: model.created_at,
updated_at: model.updated_at,
},
ncMeta
);

4
packages/nocodb/src/lib/models/ProjectUser.ts

@ -20,15 +20,13 @@ export default class ProjectUser {
}
public static async insert(
projectUser: Partial<ProjectUser & { created_at?: any; updated_at?: any }>,
projectUser: Partial<ProjectUser>,
ncMeta = Noco.ncMeta
) {
const insertObj = extractProps(projectUser, [
'fk_user_id',
'project_id',
'roles',
'created_at',
'updated_at',
]);
const { project_id, fk_user_id } = await ncMeta.metaInsert2(

35
packages/nocodb/src/lib/version-upgrader/ncProjectUpgraderV2_0090000.ts

@ -92,14 +92,10 @@ async function migrateProjects(
is_meta: !!projectConfig.prefix,
type: d.client,
config: d,
created_at: project.created_at,
updated_at: project.updated_at,
inflection_column: inflection.cn,
inflection_table: inflection.tn,
};
}),
created_at: project.created_at,
updated_at: project.updated_at,
};
const p = await Project.createProject(projectBody, ncMeta);
projectsObj[p.id] = p;
@ -126,8 +122,6 @@ async function migrateProjectUsers(
project_id: projectUser.project_id,
fk_user_id: projectUser.user_id,
roles: projectUser.roles,
created_at: projectUser.created_at,
updated_at: projectUser.updated_at,
},
ncMeta
);
@ -268,8 +262,6 @@ interface ModelMetav1 {
m_to_m_meta: string;
order: number;
view_order: number;
created_at;
updated_at;
}
type ObjModelColumnRefv1 = {
@ -406,8 +398,6 @@ async function migrateProjectModels(
title: modelData.alias,
// todo: sanitize
type: modelData.type === 'table' ? ModelTypes.TABLE : ModelTypes.VIEW,
created_at: modelData.created_at,
updated_at: modelData.updated_at,
mm: !!modelData.mm,
},
ncMeta
@ -884,14 +874,7 @@ async function migrateProjectModelViews(
queryParams;
const insertObj: Partial<
View &
GridView &
KanbanView &
FormView &
GalleryView & {
created_at;
updated_at;
}
View & GridView & KanbanView & FormView & GalleryView
> = {
title: viewData.title,
show: true,
@ -899,8 +882,6 @@ async function migrateProjectModelViews(
fk_model_id: objModelRef[project.id][viewData.parent_model_title].id,
project_id: project.id,
base_id: baseId,
created_at: viewData.created_at,
updated_at: viewData.updated_at,
};
if (viewData.show_as === 'grid') {
@ -1083,8 +1064,6 @@ async function migrateUIAcl(ctx: MigrateCtxV1, ncMeta: any) {
tn: string;
parent_model_title: string;
project_id: string;
created_at?;
updated_at?;
}> = await ncMeta.metaList(null, null, 'nc_disabled_models_for_role');
for (const acl of uiAclList) {
@ -1117,8 +1096,6 @@ async function migrateUIAcl(ctx: MigrateCtxV1, ncMeta: any) {
role: acl.role,
fk_view_id,
disabled: acl.disabled,
created_at: acl.created_at,
updated_at: acl.updated_at,
},
ncMeta
);
@ -1217,8 +1194,6 @@ async function migratePlugins(ncMeta: any) {
creator: plugin.creator,
creator_website: plugin.creator_website,
price: plugin.price,
created_at: plugin.created_at,
updated_at: plugin.updated_at,
});
}
}
@ -1244,8 +1219,6 @@ async function migrateWebhooks(ctx: MigrateCtxV1, ncMeta: any) {
retry_interval: number;
timeout: number;
active: boolean;
created_at?;
updated_at?;
}> = await ncMeta.metaList(null, null, 'nc_hooks');
for (const hookMeta of hooks) {
@ -1275,8 +1248,6 @@ async function migrateWebhooks(ctx: MigrateCtxV1, ncMeta: any) {
retry_interval: hookMeta.retry_interval,
timeout: hookMeta.timeout,
active: hookMeta.active,
created_at: hookMeta.created_at,
updated_at: hookMeta.updated_at,
},
ncMeta
);
@ -1326,8 +1297,6 @@ async function migrateAutitLog(
status: string;
description: string;
details: string;
created_at: any;
updated_at: any;
}> = await ncMeta.metaList(null, null, 'nc_audit');
for (const audit of audits) {
@ -1344,8 +1313,6 @@ async function migrateAutitLog(
status: audit.status,
description: audit.description,
details: audit.details,
created_at: audit.created_at,
updated_at: audit.updated_at,
};
if (audit.model_name) {

88
packages/nocodb/src/schema/swagger.json

@ -7839,7 +7839,6 @@
{
"alias": null,
"config": "<ENCRYPTED>",
"created_at": "2023-03-01 16:31:49",
"enabled": 1,
"id": "ds_krsappzu9f8vmo",
"inflection_column": "camelize",
@ -7848,10 +7847,11 @@
"meta": null,
"order": 1,
"project_id": "p_01clqvzik3izk6",
"type": "mysql2",
"updated_at": "2023-03-02 11:28:17"
"type": "mysql2"
}
],
"title": "Base Model",
"type": "object",
"properties": {
"alias": {
"$ref": "#/components/schemas/StringOrNull",
@ -7860,12 +7860,6 @@
"config": {
"description": "Base Configuration"
},
"created_at": {
"description": "The datatime this base is created at",
"example": "2023-03-01 14:27:36",
"format": "date-time",
"type": "string"
},
"enabled": {
"$ref": "#/components/schemas/Bool",
"description": "Is this base enabled"
@ -7910,16 +7904,8 @@
],
"example": "mysql2",
"type": "string"
},
"updated_at": {
"description": "The datatime this base is updated at",
"example": "2023-03-01 14:27:36",
"format": "date-time",
"type": "string"
}
},
"title": "Base Model",
"type": "object"
}
},
"BaseList": {
"description": "Model for Base List",
@ -9952,7 +9938,6 @@
{
"base_id": "string",
"conditions": "string",
"created_at": "string",
"error": "string",
"error_code": "string",
"error_message": "string",
@ -9967,10 +9952,11 @@
"response": "string",
"test_call": true,
"triggered_by": "string",
"type": "string",
"updated_at": "string"
"type": "string"
}
],
"title": "Hook Log Model",
"type": "object",
"properties": {
"base_id": {
"type": "string"
@ -9978,9 +9964,6 @@
"conditions": {
"type": "string"
},
"created_at": {
"type": "string"
},
"error": {
"type": "string"
},
@ -10024,13 +10007,8 @@
},
"type": {
"type": "string"
},
"updated_at": {
"type": "string"
}
},
"title": "Hook Log Model",
"type": "object"
}
},
"HookTestReq": {
"description": "Model for Hook Test Request",
@ -11054,7 +11032,6 @@
{
"alias": "string",
"config": null,
"created_at": "2023-03-01 14:27:36",
"enabled": true,
"id": "string",
"inflection_column": "camelize",
@ -11076,29 +11053,24 @@
"order": 0,
"prefix": "nc_vm5q__",
"status": "string",
"title": "my-project",
"updated_at": "2023-03-01 14:27:36"
"title": "my-project"
}
],
"title": "Project Model",
"type": "object",
"properties": {
"bases": {
"description": "List of base models",
"type": "array",
"items": {
"$ref": "#/components/schemas/Base"
},
"type": "array"
}
},
"color": {
"description": "Primary Theme Color",
"example": "#24716E",
"type": "string"
},
"created_at": {
"description": "The created time of the record",
"example": "2023-03-01 14:27:36",
"format": "date-time",
"type": "string"
},
"deleted": {
"$ref": "#/components/schemas/Bool",
"description": "Is the project deleted"
@ -11136,16 +11108,8 @@
"description": "Project Title",
"example": "my-project",
"type": "string"
},
"updated_at": {
"description": "The updated time of the record",
"example": "2023-03-01 14:27:36",
"format": "date-time",
"type": "string"
}
},
"title": "Project Model",
"type": "object"
}
},
"ProjectList": {
"description": "Model for Project List",
@ -12527,23 +12491,18 @@
"description": "Model for User",
"examples": [
{
"created_at": "2023-03-01 11:36:49",
"email": "user@example.com",
"email_verified": true,
"firstName": "Alice",
"id": "us_8kugj628ebjngs",
"lastName": "Smith",
"roles": "org-level-viewer",
"updated_at": "2023-03-01 11:36:49"
"roles": "org-level-viewer"
}
],
"title": "User Model",
"type": "object",
"x-internal": false,
"properties": {
"created_at": {
"description": "The date that the user was created.",
"example": "2023-03-01 11:36:49",
"format": "date-time",
"type": "string"
},
"email": {
"description": "The email of the user",
"example": "user@example.com",
@ -12573,18 +12532,9 @@
"description": "The roles of the user",
"example": "org-level-viewer",
"type": "string"
},
"updated_at": {
"description": "The date that the user was created.",
"example": "2023-03-01 11:36:49",
"format": "date-time",
"type": "string"
}
},
"required": ["email", "email_verified", "firstname", "id", "lastname"],
"title": "User Model",
"type": "object",
"x-internal": false
"required": ["email", "email_verified", "firstname", "id", "lastname"]
},
"UserInfo": {
"description": "Model for User Info",

Loading…
Cancel
Save