fix: Unique constraint should account for soft deleted records (#11048)

FIXES FRMW-2878

**What**
Currently, the `one-to-one` unique constraints does not account for deleted record. This prevents from inserting a new record wth the same fk if another one is deleted.

**Caveat**
`hasOne` with FK option is meant to be a special case, for example a many to one - one to many without defining the other side of the relation. In that case we don't handle this behaviour and keep it as it is
This commit is contained in:
Adrien de Peretti authored and GitHub committed 2025-01-22 07:42:06 +00:00
1 parent ecc8efcb04
commit da3906efa4
22 files changed
+361 -217

No files matched your search

@@ -23,6 +23,11 @@ export const WorkflowExecution = model
on: ["transaction_id"],
where: "deleted_at IS NULL",
},
{
on: ["workflow_id", "transaction_id"],
unique: true,
where: "deleted_at IS NULL",
},
{
on: ["state"],
where: "deleted_at IS NULL",