Fix collection delete for collections w/ m2o to them (#5809)

* Fix new-collection relational field creation

* Fix collection delete for collections w/ m2o to them

Fixes #5793
This commit is contained in:
Rijk van Zanten
2021-05-21 13:57:42 -04:00
committed by GitHub
parent da7b539adb
commit ba2e56e43c
2 changed files with 6 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
'directus': patch
---
Fixed issue that would prevent collections that had a relationship pointing to them from being deleted.

View File

@@ -378,7 +378,7 @@ export class FieldsService {
// Cleanup directus_fields
const metaRow = await trx.select('id').from('directus_fields').where({ collection, field }).first();
if (metaRow.id) {
if (metaRow?.id) {
// Handle recursive FK constraints
await trx('directus_fields').update({ group: null }).where({ group: metaRow.id });
}