Defect #44366
closedDeleting an issue custom field does not delete its workflow field permissions
Description
What did you expect?¶
Deleting a CustomField should also delete any workflow records that refer to that CustomField
What has happened instead?¶
The workflow table contains orphaned records that reference a non-existing CustomField.
What could be a possible solution?¶
IssueStatus has a before_destroy that cleans Workflow records with it's ID. Maybe something similar could work for CustomFields too.
How can we reproduce the problem?¶
- Create a IssueCustomField
- Define some WorkflowRules for it
- Delete the CustomField
- Check the DB, the WorkflowRule should still be there
In what environment are you?¶
Please copy and paste your environment information as displayed in Administration ยป Information or run bin/about in the root dir of your Redmine instance.
Environment:
Redmine version 6.0.9.stable
Ruby version 3.3.11-p205 (2026-03-26) [x86_64-linux]
Rails version 7.2.3.1
Environment development
Database adapter Mysql2
Files
Updated by Go MAEDA 20 days ago
- File 0001-Delete-workflow-rules-referring-to-an-issue-custom-f.patch 0001-Delete-workflow-rules-referring-to-an-issue-custom-f.patch added
- Target version set to Candidate for next major release
Thank you for the report. I was able to reproduce the issue on the current trunk.
The attached patch adds before_destroy :delete_workflow_rules to IssueCustomField, as IssueStatus does. Deleting an issue custom field now also deletes the WorkflowRule records whose field_name refers to the custom field.
The patch also includes a database migration that removes workflow rules orphaned by previously deleted custom fields.
Updated by Go MAEDA 16 days ago
- File 0001-Delete-workflow-rules-referring-to-an-issue-custom-f.patch 0001-Delete-workflow-rules-referring-to-an-issue-custom-f.patch added
Attached is an updated patch.
The deletion now uses the WorkflowPermission model instead of WorkflowRule, both in the before_destroy callback and in the migration. Since the records to be deleted are WorkflowPermission records, this expresses the intent more precisely and limits the deletion to field permission rules.
Updated by Go MAEDA 5 days ago
- Subject changed from Deleting a CustomField leaves orphaned workflow records to Deleting an issue custom field does not delete its workflow field permissions
- Status changed from New to Closed
- Assignee set to Go MAEDA
- Resolution set to Fixed
Committed the fix in r25051. Thank you for reporting the issue.