Skip to content

Commit 3268a86

Browse files
authored
Skip backfill record page layouts for missing standard objects (#19799)
1 parent 68746e2 commit 3268a86

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

packages/twenty-server/src/database/commands/upgrade-version-command/1-23/1-23-workspace-command-1780000001500-backfill-record-page-layouts.command.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,17 @@ export class BackfillRecordPageLayoutsCommand extends ActiveOrSuspendedWorkspace
245245
twentyStandardApplicationId: twentyStandardFlatApplication.id,
246246
});
247247

248+
const { flatObjectMetadataMaps } =
249+
await this.workspaceCacheService.getOrRecompute(workspaceId, [
250+
'flatObjectMetadataMaps',
251+
]);
252+
253+
const existingObjectMetadataUniversalIdentifiers = new Set(
254+
Object.values(flatObjectMetadataMaps.byUniversalIdentifier)
255+
.filter(isDefined)
256+
.map((objectMetadata) => objectMetadata.universalIdentifier),
257+
);
258+
248259
const recordPageLayoutUniversalIdentifiers = new Set<string>();
249260

250261
const pageLayouts = Object.values(
@@ -256,6 +267,19 @@ export class BackfillRecordPageLayoutsCommand extends ActiveOrSuspendedWorkspace
256267
return false;
257268
}
258269

270+
if (
271+
isDefined(pageLayout.objectMetadataUniversalIdentifier) &&
272+
!existingObjectMetadataUniversalIdentifiers.has(
273+
pageLayout.objectMetadataUniversalIdentifier,
274+
)
275+
) {
276+
this.logger.log(
277+
`Skipping standard record page layout ${pageLayout.universalIdentifier} for workspace ${workspaceId}: associated object ${pageLayout.objectMetadataUniversalIdentifier} does not exist`,
278+
);
279+
280+
return false;
281+
}
282+
259283
recordPageLayoutUniversalIdentifiers.add(
260284
pageLayout.universalIdentifier,
261285
);
@@ -300,6 +324,15 @@ export class BackfillRecordPageLayoutsCommand extends ActiveOrSuspendedWorkspace
300324
return false;
301325
}
302326

327+
if (
328+
isDefined(view.objectMetadataUniversalIdentifier) &&
329+
!existingObjectMetadataUniversalIdentifiers.has(
330+
view.objectMetadataUniversalIdentifier,
331+
)
332+
) {
333+
return false;
334+
}
335+
303336
fieldsWidgetViewUniversalIdentifiers.add(view.universalIdentifier);
304337

305338
return true;

0 commit comments

Comments
 (0)