fix operations foreign key errors on Flow deletion (#15087)

This commit is contained in:
Azri Kahar
2022-08-16 23:00:01 +08:00
committed by GitHub
parent 9c0f806ed8
commit 91a36120fa

View File

@@ -56,6 +56,9 @@ export class FlowsService extends ItemsService<FlowRaw> {
async deleteOne(key: PrimaryKey, opts?: MutationOptions): Promise<PrimaryKey> {
const flowManager = getFlowManager();
// this is to prevent foreign key constraint error on directus_operations resolve/reject during cascade deletion
await this.knex('directus_operations').update({ resolve: null, reject: null }).where('flow', key);
const result = await super.deleteOne(key, opts);
await flowManager.reload();
@@ -65,6 +68,9 @@ export class FlowsService extends ItemsService<FlowRaw> {
async deleteMany(keys: PrimaryKey[], opts?: MutationOptions): Promise<PrimaryKey[]> {
const flowManager = getFlowManager();
// this is to prevent foreign key constraint error on directus_operations resolve/reject during cascade deletion
await this.knex('directus_operations').update({ resolve: null, reject: null }).whereIn('flow', keys);
const result = await super.deleteMany(keys, opts);
await flowManager.reload();