diff --git a/api/src/services/fields.ts b/api/src/services/fields.ts index 07e0b6d085..17f245c597 100644 --- a/api/src/services/fields.ts +++ b/api/src/services/fields.ts @@ -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 });