Files
twenty/packages/twenty-server/src/modules/note/standard-objects/note-target.workspace-entity.ts
T
Abdullah.andGitHub 7867617385 Migrate noteTarget and taskTarget to Morph. (#17476)
This PR migrates `noteTarget` and `taskTarget` to morph relations behind
separate feature flags, following the Attachment/TimelineActivity
pattern.

It introduces the `IS_NOTE_TARGET_MIGRATED` and
`IS_TASK_TARGET_MIGRATED` flags, updates standard field metadata and
indexes to use morph relations, and adds two **1.17 workspace
migrations** that:
- rename `noteTarget.*Id` / `taskTarget.*Id` columns to `target*Id`
- convert the corresponding field metadata to `MORPH_RELATION` with a
shared `morphId`

On the frontend, note/task target read and write paths switch to
`target*Id` when the respective flag is enabled. Deleted targets are
filtered on reload to prevent reappearing relations.
2026-02-04 02:53:06 +00:00

20 lines
1.2 KiB
TypeScript

import { BaseWorkspaceEntity } from 'src/engine/twenty-orm/base.workspace-entity';
import { type CustomWorkspaceEntity } from 'src/engine/twenty-orm/custom.workspace-entity';
import { type EntityRelation } from 'src/engine/workspace-manager/workspace-migration/types/entity-relation.interface';
import { type CompanyWorkspaceEntity } from 'src/modules/company/standard-objects/company.workspace-entity';
import { type NoteWorkspaceEntity } from 'src/modules/note/standard-objects/note.workspace-entity';
import { type OpportunityWorkspaceEntity } from 'src/modules/opportunity/standard-objects/opportunity.workspace-entity';
import { type PersonWorkspaceEntity } from 'src/modules/person/standard-objects/person.workspace-entity';
export class NoteTargetWorkspaceEntity extends BaseWorkspaceEntity {
note: EntityRelation<NoteWorkspaceEntity> | null;
noteId: string | null;
targetPerson: EntityRelation<PersonWorkspaceEntity> | null;
targetPersonId: string | null;
targetCompany: EntityRelation<CompanyWorkspaceEntity> | null;
targetCompanyId: string | null;
targetOpportunity: EntityRelation<OpportunityWorkspaceEntity> | null;
targetOpportunityId: string | null;
custom: EntityRelation<CustomWorkspaceEntity>;
}