Use adapter for removing legacy epic links
What does this MR do and why?
Use adapter for removing legacy epic links
This is migrating one more service to use the WorkItem service instead of relying on the legacy epic services. This doesn't change any behaviour as the Epic Service is already used in most use cases, except for the REST API.
References
Screenshots or screen recordings
| Before | After |
|---|---|
How to set up and validate locally
- Create an epic <> epic relationship
- Use the REST API to delete it https://docs.gitlab.com/api/epic_links/#unassign-a-child-epic
Epic.last.parent_id
Epic Load (1.1ms) SELECT "epics".* FROM "epics" ORDER BY "epics"."id" DESC LIMIT 1 /*application:console,db_config_database:gitlabhq_development,db_config_name:main,console_hostname:ndular--20250210-YF7L9,console_username:nicolas,line:(pry):3:in `__pry__'*/
=> 15
[4] pry(main)> Epic.last.work_item_parent_link_id
Epic Load (1.1ms) SELECT "epics".* FROM "epics" ORDER BY "epics"."id" DESC LIMIT 1 /*application:console,db_config_database:gitlabhq_development,db_config_name:main,console_hostname:ndular--20250210-YF7L9,console_username:nicolas,line:(pry):4:in `__pry__'*/
=> 3
Important:
- For the parent you need to use the
IID - For the child you need to use the
ID
DELETE /groups/:id/epics/:epic_iid/epics/:child_epic_id
curl --request DELETE \
--header "PRIVATE-TOKEN: <token>" \
--url "http://gdk.test:3000/api/v4/groups/gitlab/epics/9/epics/16"
{"id":16,"work_item_id":638,"iid":10,"color":"#1068bf","text_color":"#FFFFFF","group_id":105,"parent_id":15,"parent_iid":9,"imported":false,"imported_from":"none","title":"Child epic","description":null,"confidential":false,"author":{"id":70,"username":"nicolas","public_email":null,"name":"Nicolas Dular","state":"active","locked":false,"avatar_url":"https://www.gravatar.com/avatar/ba8a37e8137420c27f436c273943b83433db4188ee0caede56b93e7fba8c7a63?s=80\u0026d=identicon","web_url":"http://gdk.test:3000/nicolas"},"start_date":null,"start_date_is_fixed":false,"start_date_fixed":null,"start_date_from_inherited_source":null,"start_date_from_milestones":null,"end_date":null,"due_date":null,"due_date_is_fixed":false,"due_date_fixed":null,"due_date_from_inherited_source":null,"due_date_from_milestones":null,"state":"opened","web_edit_url":"/groups/gitlab/-/epics/10","web_url":"http://gdk.test:3000/groups/gitlab/-/epics/10","references":{"short":"\u002610","relative":"\u002610","full":"gitlab\u002610"},"created_at":"2025-11-05T19:55:44.629Z","updated_at":"2025-11-05T19:55:44.629Z","closed_at":null,"labels":[],"upvotes":0,"downvotes":0,"_links":{"self":"http://gdk.test:3000/api/v4/groups/105/epics/10","epic_issues":"http://gdk.test:3000/api/v4/groups/105/epics/10/issues","group":"http://gdk.test:3000/api/v4/groups/105","parent":"http://gdk.test:3000/api/v4/groups/105/epics/9"}}⏎
Epic.last.parent_id
Epic Load (1.0ms) SELECT "epics".* FROM "epics" ORDER BY "epics"."id" DESC LIMIT 1 /*application:console,db_config_database:gitlabhq_development,db_config_name:main,console_hostname:ndular--20250210-YF7L9,console_username:nicolas,line:(pry):5:in `__pry__'*/
=> nil
[6] pry(main)> Epic.last.work_item_parent_link_id
Epic Load (1.0ms) SELECT "epics".* FROM "epics" ORDER BY "epics"."id" DESC LIMIT 1 /*application:console,db_config_database:gitlabhq_development,db_config_name:main,console_hostname:ndular--20250210-YF7L9,console_username:nicolas,line:(pry):6:in `__pry__'*/
=> nil
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by Nicolas Dular