Browse Source

fix: audit migration - extract model id

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/1712/head
Pranav C 3 years ago
parent
commit
d5b932af0b
  1. 11
      packages/nocodb/src/lib/noco/upgrader/jobs/ncProjectUpgraderV2_0090000.ts

11
packages/nocodb/src/lib/noco/upgrader/jobs/ncProjectUpgraderV2_0090000.ts

@ -227,7 +227,7 @@ interface LinkToAnotherRecordv1 {
}
interface ModelMetav1 {
id: number;
id: number | string;
project_id: string;
db_alias: string;
title: string;
@ -296,6 +296,7 @@ interface MigrateCtxV1 {
objModelColumnAliasRef: ObjModelColumnAliasRefv1;
objViewRef: ObjViewRefv1;
objViewQPRef: ObjViewQPRefv1;
metas: ModelMetav1[];
}
// @ts-ignore
@ -786,6 +787,7 @@ async function migrateProjectModels(
await migrateProjectModelViews(
{
metas,
views,
objModelRef,
objModelColumnAliasRef,
@ -799,6 +801,7 @@ async function migrateProjectModels(
await migrateViewsParams(
{
metas,
views,
objModelRef,
objModelColumnAliasRef,
@ -811,6 +814,7 @@ async function migrateProjectModels(
);
return {
metas,
views,
objModelRef,
objModelColumnAliasRef,
@ -1270,8 +1274,9 @@ async function migrateAutitLog(ctx: MigrateCtxV1, ncMeta: any) {
if (audit.model_name) {
insertObj.fk_model_id = (
ctx.objModelAliasRef?.[audit.project_id]?.[audit.model_name] ||
ctx.objModelRef?.[audit.project_id]?.[audit.model_name]
).id;
ctx.objModelRef?.[audit.project_id]?.[audit.model_name] ||
ctx.metas?.find(m => m.id == audit.model_id)
)?.id;
}
await Audit.insert(insertObj, ncMeta);

Loading…
Cancel
Save