Fix soft delete unique constraints to allow reusing unique values after deletion (#13615)

Closes [#1297](https://github.com/twentyhq/core-team-issues/issues/1297)
This commit is contained in:
Abdul Rahman
2025-08-05 11:27:02 +05:30
committed by GitHub
parent ade7f8b6ae
commit b2452e83ad
5 changed files with 89 additions and 17 deletions
@@ -8,7 +8,6 @@ import {
ManyToOne,
OneToMany,
PrimaryGeneratedColumn,
Unique,
UpdateDateColumn,
} from 'typeorm';
@@ -22,7 +21,10 @@ import { AgentHandoffEntity } from './agent-handoff.entity';
@Entity('agent')
@Index('IDX_AGENT_ID_DELETED_AT', ['id', 'deletedAt'])
@Unique('IDX_AGENT_NAME_WORKSPACE_ID_UNIQUE', ['name', 'workspaceId'])
@Index('IDX_AGENT_NAME_WORKSPACE_ID_UNIQUE', ['name', 'workspaceId'], {
unique: true,
where: '"deletedAt" IS NULL',
})
export class AgentEntity {
@PrimaryGeneratedColumn('uuid')
id: string;