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:
+8
-5
@@ -14,7 +14,6 @@ import {
|
||||
OneToMany,
|
||||
PrimaryGeneratedColumn,
|
||||
Relation,
|
||||
Unique,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
@@ -36,10 +35,14 @@ registerEnumType(PermissionsOnAllObjectRecords, {
|
||||
|
||||
@Entity({ name: 'userWorkspace', schema: 'core' })
|
||||
@ObjectType()
|
||||
@Unique('IDX_USER_WORKSPACE_USER_ID_WORKSPACE_ID_UNIQUE', [
|
||||
'userId',
|
||||
'workspaceId',
|
||||
])
|
||||
@Index(
|
||||
'IDX_USER_WORKSPACE_USER_ID_WORKSPACE_ID_UNIQUE',
|
||||
['userId', 'workspaceId'],
|
||||
{
|
||||
unique: true,
|
||||
where: '"deletedAt" IS NULL',
|
||||
},
|
||||
)
|
||||
@Index('IDX_USER_WORKSPACE_USER_ID', ['userId'])
|
||||
@Index('IDX_USER_WORKSPACE_WORKSPACE_ID', ['workspaceId'])
|
||||
export class UserWorkspace {
|
||||
|
||||
Reference in New Issue
Block a user