Skip to content

Add new column to work items hierarchy restrictions table

Related to #424896 (closed)

What does this MR do and why?

Currently, we don't allow cross-hierarchy relationships in work items (parent and child must belong to the same group or project) but this ability can be required for certain types.

To be able to control which types support cross-hierarchy relationships this MR adds a new column cross_hierarchy_enabled to the work_item_hierarchy_restrictions table which is disabled by default. It also modifies the validations in WorkItems::ParentLink to make use of this new attribute.

The resulting validations will behave the same until we update cross_hierarchy_enabled for some of the existing records (this will be done in a follow-up).

Database

UP

bin/rails db:migrate:up:main VERSION=20230918091159
WARNING: This version of GitLab depends on gitlab-shell 14.27.0, but you're running 14.26.0. Please update gitlab-shell.
main: == [advisory_lock_connection] object_id: 226020, pg_backend_pid: 45239
main: == 20230918091159 AddCrossHierarchyEnabledToHierarchyRestrictions: migrating ==
main: -- add_column(:work_item_hierarchy_restrictions, :cross_hierarchy_enabled, :boolean, {:default=>false, :null=>false})
main:    -> 0.0031s
main: == 20230918091159 AddCrossHierarchyEnabledToHierarchyRestrictions: migrated (0.0070s)

main: == [advisory_lock_connection] object_id: 226020, pg_backend_pid: 45239

DOWN

bin/rails db:migrate:down:main VERSION=20230918091159
WARNING: This version of GitLab depends on gitlab-shell 14.27.0, but you're running 14.26.0. Please update gitlab-shell.
main: == [advisory_lock_connection] object_id: 231520, pg_backend_pid: 44615
main: == 20230918091159 AddCrossHierarchyEnabledToHierarchyRestrictions: reverting ==
main: -- remove_column(:work_item_hierarchy_restrictions, :cross_hierarchy_enabled, :boolean, {:default=>true, :null=>false})
main:    -> 0.0011s
main: == 20230918091159 AddCrossHierarchyEnabledToHierarchyRestrictions: reverted (0.0065s)

main: == [advisory_lock_connection] object_id: 231520, pg_backend_pid: 44615

Screenshots or screen recordings

No UI changes

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Eugenia Grieff

Merge request reports