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

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

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

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

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

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

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

Loading…
Cancel
Save