mirror of
https://github.com/directus/directus.git
synced 2026-01-23 23:18:10 -05:00
fix directus_fields group cleanup on delete (#8707)
This commit is contained in:
@@ -397,11 +397,17 @@ export class FieldsService {
|
||||
}
|
||||
|
||||
// Cleanup directus_fields
|
||||
const metaRow = await trx.select('id').from('directus_fields').where({ collection, field }).first();
|
||||
const metaRow = await trx
|
||||
.select('collection', 'field')
|
||||
.from('directus_fields')
|
||||
.where({ collection, field })
|
||||
.first();
|
||||
|
||||
if (metaRow?.id) {
|
||||
if (metaRow) {
|
||||
// Handle recursive FK constraints
|
||||
await trx('directus_fields').update({ group: null }).where({ group: metaRow.id });
|
||||
await trx('directus_fields')
|
||||
.update({ group: null })
|
||||
.where({ group: metaRow.field, collection: metaRow.collection });
|
||||
}
|
||||
|
||||
await trx('directus_fields').delete().where({ collection, field });
|
||||
|
||||
Reference in New Issue
Block a user