From 3e57aa14d3901ce25a0654170248bab09450eb97 Mon Sep 17 00:00:00 2001 From: Paul Rastoin <45004772+prastoin@users.noreply.github.com> Date: Sat, 6 Dec 2025 10:23:24 +0100 Subject: [PATCH] Refactor page layout tab and widgets migration (#16367) # Introduction Making columns nullable instead of required + metadata on the fly migration in typeorm migration that could affect other breaking change migrations to be run --- ...ge-layout-universal-identifiers.command.ts | 143 ++++++++++++++++++ .../1-13-upgrade-version-command.module.ts | 11 ++ .../upgrade.command.ts | 3 + ...entifierAndApplicationIdToPageLayoutTab.ts | 60 -------- ...nIdAndUniversalIdentifierToPageLayouts.ts} | 46 +++--- ...tab-entity-to-flat-page-layout-tab.util.ts | 3 +- .../entities/page-layout-tab.entity.ts | 4 +- .../entities/page-layout-widget.entity.ts | 4 +- .../strict-syncable-entity.interface.ts | 21 --- 9 files changed, 186 insertions(+), 109 deletions(-) create mode 100644 packages/twenty-server/src/database/commands/upgrade-version-command/1-13/1-13-backfill-page-layout-universal-identifiers.command.ts delete mode 100644 packages/twenty-server/src/database/typeorm/core/migrations/common/1764854150563-addUniversalIdentifierAndApplicationIdToPageLayoutTab.ts rename packages/twenty-server/src/database/typeorm/core/migrations/common/{1764858276847-addUniversalIdentifierAndApplicationIdToPageLayoutWidget.ts => 1764949394792-addApplicationIdAndUniversalIdentifierToPageLayouts.ts} (53%) delete mode 100644 packages/twenty-server/src/engine/workspace-manager/workspace-sync/interfaces/strict-syncable-entity.interface.ts diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/1-13/1-13-backfill-page-layout-universal-identifiers.command.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/1-13/1-13-backfill-page-layout-universal-identifiers.command.ts new file mode 100644 index 0000000000..fe8150a7da --- /dev/null +++ b/packages/twenty-server/src/database/commands/upgrade-version-command/1-13/1-13-backfill-page-layout-universal-identifiers.command.ts @@ -0,0 +1,143 @@ +import { InjectRepository } from '@nestjs/typeorm'; + +import { Command } from 'nest-commander'; +import { IsNull, Repository } from 'typeorm'; +import { v4 } from 'uuid'; + +import { ActiveOrSuspendedWorkspacesMigrationCommandRunner } from 'src/database/commands/command-runners/active-or-suspended-workspaces-migration.command-runner'; +import { RunOnWorkspaceArgs } from 'src/database/commands/command-runners/workspaces-migration.command-runner'; +import { ApplicationService } from 'src/engine/core-modules/application/application.service'; +import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity'; +import { DataSourceService } from 'src/engine/metadata-modules/data-source/data-source.service'; +import { PageLayoutTabEntity } from 'src/engine/metadata-modules/page-layout/entities/page-layout-tab.entity'; +import { PageLayoutWidgetEntity } from 'src/engine/metadata-modules/page-layout/entities/page-layout-widget.entity'; +import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager'; +import { WorkspaceCacheService } from 'src/engine/workspace-cache/services/workspace-cache.service'; + +@Command({ + name: 'upgrade:1-13:backfill-page-layout-universal-identifiers', + description: + 'Backfill universalIdentifier and applicationId for pageLayoutWidget and pageLayoutTab', +}) +export class BackfillPageLayoutUniversalIdentifiersCommand extends ActiveOrSuspendedWorkspacesMigrationCommandRunner { + constructor( + @InjectRepository(WorkspaceEntity) + protected readonly workspaceRepository: Repository, + @InjectRepository(PageLayoutWidgetEntity) + private readonly pageLayoutWidgetRepository: Repository, + @InjectRepository(PageLayoutTabEntity) + private readonly pageLayoutTabRepository: Repository, + protected readonly twentyORMGlobalManager: TwentyORMGlobalManager, + protected readonly dataSourceService: DataSourceService, + private readonly applicationService: ApplicationService, + private readonly workspaceCacheService: WorkspaceCacheService, + ) { + super(workspaceRepository, twentyORMGlobalManager, dataSourceService); + } + + override async runOnWorkspace({ + workspaceId, + options, + }: RunOnWorkspaceArgs): Promise { + this.logger.log( + `Starting backfill of universalIdentifier and applicationId for workspace ${workspaceId}`, + ); + + const { workspaceCustomFlatApplication } = + await this.applicationService.findWorkspaceTwentyStandardAndCustomApplicationOrThrow( + { + workspaceId, + }, + ); + + const applicationId = workspaceCustomFlatApplication.id; + + const widgetsToUpdate = await this.pageLayoutWidgetRepository.find({ + where: [ + { workspaceId, universalIdentifier: IsNull() }, + { workspaceId, applicationId: IsNull() }, + ], + select: ['id', 'workspaceId'], + }); + + this.logger.log( + `Found ${widgetsToUpdate.length} pageLayoutWidget records to backfill`, + ); + + for (const widget of widgetsToUpdate) { + const universalIdentifier = v4(); + + if (options.dryRun) { + this.logger.log( + `[DRY RUN] Would update pageLayoutWidget ${widget.id} with universalIdentifier ${universalIdentifier} and applicationId ${applicationId}`, + ); + } else { + await this.pageLayoutWidgetRepository.update( + { id: widget.id }, + { + universalIdentifier, + applicationId, + }, + ); + + this.logger.log( + `Updated pageLayoutWidget ${widget.id} with universalIdentifier ${universalIdentifier}`, + ); + } + } + + const tabsToUpdate = await this.pageLayoutTabRepository.find({ + where: [ + { workspaceId, universalIdentifier: IsNull() }, + { workspaceId, applicationId: IsNull() }, + ], + select: ['id', 'workspaceId'], + }); + + this.logger.log( + `Found ${tabsToUpdate.length} pageLayoutTab records to backfill`, + ); + + for (const tab of tabsToUpdate) { + const universalIdentifier = v4(); + + if (options.dryRun) { + this.logger.log( + `[DRY RUN] Would update pageLayoutTab ${tab.id} with universalIdentifier ${universalIdentifier} and applicationId ${applicationId}`, + ); + } else { + await this.pageLayoutTabRepository.update( + { id: tab.id }, + { + universalIdentifier, + applicationId, + }, + ); + + this.logger.log( + `Updated pageLayoutTab ${tab.id} with universalIdentifier ${universalIdentifier}`, + ); + } + } + + this.logger.log( + `${options.dryRun ? '[DRY RUN] Would have ' : ''}Successfully backfilled ${widgetsToUpdate.length} widgets and ${tabsToUpdate.length} tabs`, + ); + + if ( + !options.dryRun && + (tabsToUpdate.length > 0 || widgetsToUpdate.length > 0) + ) { + this.logger.log( + `Invalidating and recomputing cache for workspace ${workspaceId}`, + ); + + await this.workspaceCacheService.invalidateAndRecompute(workspaceId, [ + 'flatPageLayoutTabMaps', + 'flatPageLayoutWidgetMaps', + ]); + + this.logger.log(`Cache invalidated and recomputed successfully`); + } + } +} diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/1-13/1-13-upgrade-version-command.module.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/1-13/1-13-upgrade-version-command.module.ts index 9b9af06d8c..f0838b25c3 100644 --- a/packages/twenty-server/src/database/commands/upgrade-version-command/1-13/1-13-upgrade-version-command.module.ts +++ b/packages/twenty-server/src/database/commands/upgrade-version-command/1-13/1-13-upgrade-version-command.module.ts @@ -1,18 +1,23 @@ import { Module } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; +import { BackfillPageLayoutUniversalIdentifiersCommand } from 'src/database/commands/upgrade-version-command/1-13/1-13-backfill-page-layout-universal-identifiers.command'; import { BackfillViewMainGroupByFieldMetadataIdCommand } from 'src/database/commands/upgrade-version-command/1-13/1-13-backfill-view-main-group-by-field-metadata-id.command'; import { CleanEmptyStringNullInTextFieldsCommand } from 'src/database/commands/upgrade-version-command/1-13/1-13-clean-empty-string-null-in-text-fields.command'; import { DeduplicateRoleTargetsCommand } from 'src/database/commands/upgrade-version-command/1-13/1-13-deduplicate-role-targets.command'; import { UpdateRoleTargetsUniqueConstraintMigrationCommand } from 'src/database/commands/upgrade-version-command/1-13/1-13-update-role-targets-unique-constraint-migration.command'; +import { ApplicationModule } from 'src/engine/core-modules/application/application.module'; import { FeatureFlagEntity } from 'src/engine/core-modules/feature-flag/feature-flag.entity'; import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity'; import { DataSourceModule } from 'src/engine/metadata-modules/data-source/data-source.module'; import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity'; import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity'; +import { PageLayoutTabEntity } from 'src/engine/metadata-modules/page-layout/entities/page-layout-tab.entity'; +import { PageLayoutWidgetEntity } from 'src/engine/metadata-modules/page-layout/entities/page-layout-widget.entity'; import { RoleTargetEntity } from 'src/engine/metadata-modules/role-target/role-target.entity'; import { ViewGroupEntity } from 'src/engine/metadata-modules/view-group/entities/view-group.entity'; import { ViewEntity } from 'src/engine/metadata-modules/view/entities/view.entity'; +import { WorkspaceCacheModule } from 'src/engine/workspace-cache/workspace-cache.module'; @Module({ imports: [ @@ -24,18 +29,24 @@ import { ViewEntity } from 'src/engine/metadata-modules/view/entities/view.entit ViewGroupEntity, FeatureFlagEntity, RoleTargetEntity, + PageLayoutWidgetEntity, + PageLayoutTabEntity, ]), DataSourceModule, + ApplicationModule, + WorkspaceCacheModule, ], providers: [ CleanEmptyStringNullInTextFieldsCommand, BackfillViewMainGroupByFieldMetadataIdCommand, + BackfillPageLayoutUniversalIdentifiersCommand, DeduplicateRoleTargetsCommand, UpdateRoleTargetsUniqueConstraintMigrationCommand, ], exports: [ CleanEmptyStringNullInTextFieldsCommand, BackfillViewMainGroupByFieldMetadataIdCommand, + BackfillPageLayoutUniversalIdentifiersCommand, DeduplicateRoleTargetsCommand, UpdateRoleTargetsUniqueConstraintMigrationCommand, ], diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/upgrade.command.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/upgrade.command.ts index 75cbd0769c..84cd350622 100644 --- a/packages/twenty-server/src/database/commands/upgrade-version-command/upgrade.command.ts +++ b/packages/twenty-server/src/database/commands/upgrade-version-command/upgrade.command.ts @@ -27,6 +27,7 @@ import { CleanNullEquivalentValuesCommand } from 'src/database/commands/upgrade- import { CreateWorkspaceCustomApplicationCommand } from 'src/database/commands/upgrade-version-command/1-12/1-12-create-workspace-custom-application.command'; import { SetStandardApplicationNotUninstallableCommand } from 'src/database/commands/upgrade-version-command/1-12/1-12-set-standard-application-not-uninstallable.command'; import { WorkspaceCustomApplicationIdNonNullableCommand } from 'src/database/commands/upgrade-version-command/1-12/1-12-workspace-custom-application-id-non-nullable-migration.command'; +import { BackfillPageLayoutUniversalIdentifiersCommand } from 'src/database/commands/upgrade-version-command/1-13/1-13-backfill-page-layout-universal-identifiers.command'; import { DeduplicateRoleTargetsCommand } from 'src/database/commands/upgrade-version-command/1-13/1-13-deduplicate-role-targets.command'; import { UpdateRoleTargetsUniqueConstraintMigrationCommand } from 'src/database/commands/upgrade-version-command/1-13/1-13-update-role-targets-unique-constraint-migration.command'; import { FixLabelIdentifierPositionAndVisibilityCommand } from 'src/database/commands/upgrade-version-command/1-6/1-6-fix-label-identifier-position-and-visibility.command'; @@ -98,6 +99,7 @@ export class UpgradeCommand extends UpgradeCommandRunner { // 1.13 Commands protected readonly deduplicateRoleTargetsCommand: DeduplicateRoleTargetsCommand, protected readonly updateRoleTargetsUniqueConstraintMigrationCommand: UpdateRoleTargetsUniqueConstraintMigrationCommand, + protected readonly backfillPageLayoutUniversalIdentifiersCommand: BackfillPageLayoutUniversalIdentifiersCommand, ) { super( workspaceRepository, @@ -169,6 +171,7 @@ export class UpgradeCommand extends UpgradeCommandRunner { beforeSyncMetadata: [ this.deduplicateRoleTargetsCommand, this.updateRoleTargetsUniqueConstraintMigrationCommand, + this.backfillPageLayoutUniversalIdentifiersCommand, ], afterSyncMetadata: [], }; diff --git a/packages/twenty-server/src/database/typeorm/core/migrations/common/1764854150563-addUniversalIdentifierAndApplicationIdToPageLayoutTab.ts b/packages/twenty-server/src/database/typeorm/core/migrations/common/1764854150563-addUniversalIdentifierAndApplicationIdToPageLayoutTab.ts deleted file mode 100644 index 91ad28e910..0000000000 --- a/packages/twenty-server/src/database/typeorm/core/migrations/common/1764854150563-addUniversalIdentifierAndApplicationIdToPageLayoutTab.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { type MigrationInterface, type QueryRunner } from 'typeorm'; - -export class AddUniversalIdentifierAndApplicationIdToPageLayoutTab1764854150563 - implements MigrationInterface -{ - name = 'AddUniversalIdentifierAndApplicationIdToPageLayoutTab1764854150563'; - - public async up(queryRunner: QueryRunner): Promise { - // Add columns as nullable first - await queryRunner.query( - `ALTER TABLE "core"."pageLayoutTab" ADD "universalIdentifier" uuid`, - ); - await queryRunner.query( - `ALTER TABLE "core"."pageLayoutTab" ADD "applicationId" uuid`, - ); - - // Populate existing rows with universalIdentifier and applicationId - await queryRunner.query( - `UPDATE "core"."pageLayoutTab" - SET "universalIdentifier" = gen_random_uuid(), - "applicationId" = ( - SELECT "workspaceCustomApplicationId" - FROM "core"."workspace" - WHERE "workspace"."id" = "pageLayoutTab"."workspaceId" - ) - WHERE "universalIdentifier" IS NULL OR "applicationId" IS NULL`, - ); - - // Add NOT NULL constraints - await queryRunner.query( - `ALTER TABLE "core"."pageLayoutTab" ALTER COLUMN "universalIdentifier" SET NOT NULL`, - ); - await queryRunner.query( - `ALTER TABLE "core"."pageLayoutTab" ALTER COLUMN "applicationId" SET NOT NULL`, - ); - - // Add unique index and foreign key - await queryRunner.query( - `CREATE UNIQUE INDEX "IDX_3763c4e8f942ff1e24040a13a9" ON "core"."pageLayoutTab" ("workspaceId", "universalIdentifier")`, - ); - await queryRunner.query( - `ALTER TABLE "core"."pageLayoutTab" ADD CONSTRAINT "FK_4493447c2e4029aa26cabf30460" FOREIGN KEY ("applicationId") REFERENCES "core"."application"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "core"."pageLayoutTab" DROP CONSTRAINT "FK_4493447c2e4029aa26cabf30460"`, - ); - await queryRunner.query( - `DROP INDEX "core"."IDX_3763c4e8f942ff1e24040a13a9"`, - ); - await queryRunner.query( - `ALTER TABLE "core"."pageLayoutTab" DROP COLUMN "applicationId"`, - ); - await queryRunner.query( - `ALTER TABLE "core"."pageLayoutTab" DROP COLUMN "universalIdentifier"`, - ); - } -} diff --git a/packages/twenty-server/src/database/typeorm/core/migrations/common/1764858276847-addUniversalIdentifierAndApplicationIdToPageLayoutWidget.ts b/packages/twenty-server/src/database/typeorm/core/migrations/common/1764949394792-addApplicationIdAndUniversalIdentifierToPageLayouts.ts similarity index 53% rename from packages/twenty-server/src/database/typeorm/core/migrations/common/1764858276847-addUniversalIdentifierAndApplicationIdToPageLayoutWidget.ts rename to packages/twenty-server/src/database/typeorm/core/migrations/common/1764949394792-addApplicationIdAndUniversalIdentifierToPageLayouts.ts index 3a24e629e3..e4e7654683 100644 --- a/packages/twenty-server/src/database/typeorm/core/migrations/common/1764858276847-addUniversalIdentifierAndApplicationIdToPageLayoutWidget.ts +++ b/packages/twenty-server/src/database/typeorm/core/migrations/common/1764949394792-addApplicationIdAndUniversalIdentifierToPageLayouts.ts @@ -1,56 +1,56 @@ import { type MigrationInterface, type QueryRunner } from 'typeorm'; -export class AddUniversalIdentifierAndApplicationIdToPageLayoutWidget1764858276847 +export class AddApplicationIdAndUniversalIdentifierToPageLayouts1764949394792 implements MigrationInterface { - name = - 'AddUniversalIdentifierAndApplicationIdToPageLayoutWidget1764858276847'; + name = 'AddApplicationIdAndUniversalIdentifierToPageLayouts1764949394792'; public async up(queryRunner: QueryRunner): Promise { - // Add columns as nullable first await queryRunner.query( `ALTER TABLE "core"."pageLayoutWidget" ADD "universalIdentifier" uuid`, ); await queryRunner.query( `ALTER TABLE "core"."pageLayoutWidget" ADD "applicationId" uuid`, ); - - // Populate existing rows with universalIdentifier and applicationId await queryRunner.query( - `UPDATE "core"."pageLayoutWidget" - SET "universalIdentifier" = gen_random_uuid(), - "applicationId" = ( - SELECT "workspaceCustomApplicationId" - FROM "core"."workspace" - WHERE "workspace"."id" = "pageLayoutWidget"."workspaceId" - ) - WHERE "universalIdentifier" IS NULL OR "applicationId" IS NULL`, - ); - - // Add NOT NULL constraints - await queryRunner.query( - `ALTER TABLE "core"."pageLayoutWidget" ALTER COLUMN "universalIdentifier" SET NOT NULL`, + `ALTER TABLE "core"."pageLayoutTab" ADD "universalIdentifier" uuid`, ); await queryRunner.query( - `ALTER TABLE "core"."pageLayoutWidget" ALTER COLUMN "applicationId" SET NOT NULL`, + `ALTER TABLE "core"."pageLayoutTab" ADD "applicationId" uuid`, ); - - // Add unique index and foreign key await queryRunner.query( - `CREATE UNIQUE INDEX "IDX_2a33a0e7e44c393ca7bb578dae" ON "core"."pageLayoutWidget" ("workspaceId", "universalIdentifier")`, + `CREATE UNIQUE INDEX "IDX_2a33a0e7e44c393ca7bb578dae" ON "core"."pageLayoutWidget" ("workspaceId", "universalIdentifier") `, + ); + await queryRunner.query( + `CREATE UNIQUE INDEX "IDX_3763c4e8f942ff1e24040a13a9" ON "core"."pageLayoutTab" ("workspaceId", "universalIdentifier") `, ); await queryRunner.query( `ALTER TABLE "core"."pageLayoutWidget" ADD CONSTRAINT "FK_fb84d310b4cfe5916ced6fc3e2a" FOREIGN KEY ("applicationId") REFERENCES "core"."application"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, ); + await queryRunner.query( + `ALTER TABLE "core"."pageLayoutTab" ADD CONSTRAINT "FK_4493447c2e4029aa26cabf30460" FOREIGN KEY ("applicationId") REFERENCES "core"."application"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); } public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "core"."pageLayoutTab" DROP CONSTRAINT "FK_4493447c2e4029aa26cabf30460"`, + ); await queryRunner.query( `ALTER TABLE "core"."pageLayoutWidget" DROP CONSTRAINT "FK_fb84d310b4cfe5916ced6fc3e2a"`, ); + await queryRunner.query( + `DROP INDEX "core"."IDX_3763c4e8f942ff1e24040a13a9"`, + ); await queryRunner.query( `DROP INDEX "core"."IDX_2a33a0e7e44c393ca7bb578dae"`, ); + await queryRunner.query( + `ALTER TABLE "core"."pageLayoutTab" DROP COLUMN "applicationId"`, + ); + await queryRunner.query( + `ALTER TABLE "core"."pageLayoutTab" DROP COLUMN "universalIdentifier"`, + ); await queryRunner.query( `ALTER TABLE "core"."pageLayoutWidget" DROP COLUMN "applicationId"`, ); diff --git a/packages/twenty-server/src/engine/metadata-modules/flat-page-layout-tab/utils/transform-page-layout-tab-entity-to-flat-page-layout-tab.util.ts b/packages/twenty-server/src/engine/metadata-modules/flat-page-layout-tab/utils/transform-page-layout-tab-entity-to-flat-page-layout-tab.util.ts index c2f5702d2e..3ee058ad03 100644 --- a/packages/twenty-server/src/engine/metadata-modules/flat-page-layout-tab/utils/transform-page-layout-tab-entity-to-flat-page-layout-tab.util.ts +++ b/packages/twenty-server/src/engine/metadata-modules/flat-page-layout-tab/utils/transform-page-layout-tab-entity-to-flat-page-layout-tab.util.ts @@ -13,7 +13,8 @@ export const transformPageLayoutTabEntityToFlatPageLayoutTab = ( position: pageLayoutTabEntity.position, pageLayoutId: pageLayoutTabEntity.pageLayoutId, workspaceId: pageLayoutTabEntity.workspaceId, - universalIdentifier: pageLayoutTabEntity.universalIdentifier, + universalIdentifier: + pageLayoutTabEntity.universalIdentifier ?? pageLayoutTabEntity.id, applicationId: pageLayoutTabEntity.applicationId, }; }; diff --git a/packages/twenty-server/src/engine/metadata-modules/page-layout/entities/page-layout-tab.entity.ts b/packages/twenty-server/src/engine/metadata-modules/page-layout/entities/page-layout-tab.entity.ts index f73e672df4..b72ac0c59b 100644 --- a/packages/twenty-server/src/engine/metadata-modules/page-layout/entities/page-layout-tab.entity.ts +++ b/packages/twenty-server/src/engine/metadata-modules/page-layout/entities/page-layout-tab.entity.ts @@ -14,7 +14,7 @@ import { UpdateDateColumn, } from 'typeorm'; -import { StrictSyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/strict-syncable-entity.interface'; +import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/syncable-entity.interface'; import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity'; import { PageLayoutWidgetEntity } from 'src/engine/metadata-modules/page-layout/entities/page-layout-widget.entity'; @@ -28,7 +28,7 @@ import { PageLayoutEntity } from 'src/engine/metadata-modules/page-layout/entiti { where: '"deletedAt" IS NULL' }, ) export class PageLayoutTabEntity - extends StrictSyncableEntity + extends SyncableEntity implements Required { @PrimaryGeneratedColumn('uuid') diff --git a/packages/twenty-server/src/engine/metadata-modules/page-layout/entities/page-layout-widget.entity.ts b/packages/twenty-server/src/engine/metadata-modules/page-layout/entities/page-layout-widget.entity.ts index 95308d571b..0e30457ab2 100644 --- a/packages/twenty-server/src/engine/metadata-modules/page-layout/entities/page-layout-widget.entity.ts +++ b/packages/twenty-server/src/engine/metadata-modules/page-layout/entities/page-layout-widget.entity.ts @@ -13,7 +13,7 @@ import { UpdateDateColumn, } from 'typeorm'; -import { StrictSyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/strict-syncable-entity.interface'; +import { SyncableEntity } from 'src/engine/workspace-manager/workspace-sync/interfaces/syncable-entity.interface'; import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity'; import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity'; @@ -30,7 +30,7 @@ import { GridPosition } from 'src/engine/metadata-modules/page-layout/types/grid { where: '"deletedAt" IS NULL' }, ) export class PageLayoutWidgetEntity - extends StrictSyncableEntity + extends SyncableEntity implements Required { @PrimaryGeneratedColumn('uuid') diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-sync/interfaces/strict-syncable-entity.interface.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-sync/interfaces/strict-syncable-entity.interface.ts deleted file mode 100644 index 7c7f62fbf7..0000000000 --- a/packages/twenty-server/src/engine/workspace-manager/workspace-sync/interfaces/strict-syncable-entity.interface.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Column, Index, JoinColumn, ManyToOne, Relation } from 'typeorm'; - -import type { ApplicationEntity } from 'src/engine/core-modules/application/application.entity'; - -@Index(['workspaceId', 'universalIdentifier'], { - unique: true, -}) -export abstract class StrictSyncableEntity { - @Column({ nullable: false, type: 'uuid' }) - universalIdentifier: string; - - @Column({ nullable: false, type: 'uuid' }) - applicationId: string; - - @ManyToOne('ApplicationEntity', { - onDelete: 'CASCADE', - nullable: false, - }) - @JoinColumn({ name: 'applicationId' }) - application: Relation; -}