Add member_role_id to group_group_links
What does this MR do and why?
- Adds
member_role_id
toGroupGroupLink
model so groups can be invited to a group with a custom role.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Database
Before
After
migrate output
Running: `bundle exec rake db:migrate:main`
main: == [advisory_lock_connection] object_id: 115780, pg_backend_pid: 177
main: == 20240625050115 AddMemberRoleIdToGroupGroupLinks: migrating =================
main: -- add_column(:group_group_links, :member_role_id, :bigint, {:if_not_exists=>true})
main: -> 0.0077s
main: == 20240625050115 AddMemberRoleIdToGroupGroupLinks: migrated (0.0132s) ========
main: == 20240625050140 AddFkToMemberRoleOnGroupGroupLinks: migrating ===============
main: -- transaction_open?(nil)
main: -> 0.0000s
main: -- transaction_open?(nil)
main: -> 0.0000s
main: -- execute("ALTER TABLE group_group_links ADD CONSTRAINT fk_2fbc7071a3 FOREIGN KEY (member_role_id) REFERENCES member_roles (id) ON DELETE SET NULL NOT VALID;")
main: -> 0.0012s
main: -- execute("SET statement_timeout TO 0")
main: -> 0.0005s
main: -- execute("ALTER TABLE group_group_links VALIDATE CONSTRAINT fk_2fbc7071a3;")
main: -> 0.0011s
main: -- execute("RESET statement_timeout")
main: -> 0.0005s
main: == 20240625050140 AddFkToMemberRoleOnGroupGroupLinks: migrated (0.0303s) ======
main: == 20240625050225 AddIndexToGroupGroupLinksOnMemberRoleId: migrating ==========
main: -- transaction_open?(nil)
main: -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main: -> 0.0008s
main: -- index_exists?(:group_group_links, :member_role_id, {:name=>"index_group_group_links_on_member_role_id", :algorithm=>:concurrently})
main: -> 0.0038s
main: -- add_index(:group_group_links, :member_role_id, {:name=>"index_group_group_links_on_member_role_id", :algorithm=>:concurrently})
main: -> 0.0011s
main: == 20240625050225 AddIndexToGroupGroupLinksOnMemberRoleId: migrated (0.0209s) =
main: == [advisory_lock_connection] object_id: 115780, pg_backend_pid: 177
rollback output
Running: `bundle exec rake db:migrate:down:main VERSION=20240625050225`
main: == [advisory_lock_connection] object_id: 115940, pg_backend_pid: 124
main: == 20240625050225 AddIndexToGroupGroupLinksOnMemberRoleId: reverting ==========
main: -- transaction_open?(nil)
main: -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main: -> 0.0193s
main: -- indexes(:group_group_links)
main: -> 0.0051s
main: -- execute("SET statement_timeout TO 0")
main: -> 0.0004s
main: -- remove_index(:group_group_links, {:algorithm=>:concurrently, :name=>"index_group_group_links_on_member_role_id"})
main: -> 0.0012s
main: -- execute("RESET statement_timeout")
main: -> 0.0004s
main: == 20240625050225 AddIndexToGroupGroupLinksOnMemberRoleId: reverted (0.0459s) =
main: == [advisory_lock_connection] object_id: 115940, pg_backend_pid: 124
$ scripts/db_tasks db:migrate:down VERSION=20240625050140
Running: `bundle exec rake db:migrate:down:main VERSION=20240625050140`
main: == [advisory_lock_connection] object_id: 115500, pg_backend_pid: 140
main: == 20240625050140 AddFkToMemberRoleOnGroupGroupLinks: reverting ===============
main: -- transaction_open?(nil)
main: -> 0.0000s
main: -- remove_foreign_key(:group_group_links, {:column=>:member_role_id})
main: -> 0.0085s
main: == 20240625050140 AddFkToMemberRoleOnGroupGroupLinks: reverted (0.0251s) ======
main: == [advisory_lock_connection] object_id: 115500, pg_backend_pid: 140
$ scripts/db_tasks db:migrate:down VERSION=20240625050115
Running: `bundle exec rake db:migrate:down:main VERSION=20240625050115`
main: == [advisory_lock_connection] object_id: 115500, pg_backend_pid: 156
main: == 20240625050115 AddMemberRoleIdToGroupGroupLinks: reverting =================
main: -- remove_column(:group_group_links, :member_role_id, :bigint, {:if_not_exists=>true})
main: -> 0.0015s
main: == 20240625050115 AddMemberRoleIdToGroupGroupLinks: reverted (0.0097s) ========
main: == [advisory_lock_connection] object_id: 115500, pg_backend_pid: 156
How to set up and validate locally
-
Make you are on an Ultimate license and you have SaaS mode off.
-
Create a private group called the
SRE Group
and invite a user,kate
as theGuest
of that group. -
Create another group, called
Group A
. On theManage > Members
page, use the button andInvite a group
and inviteSRE Group
with aGuest role
-
Log-in as
kate
and navigate toGroup A
. You should not be able to see anySettings
page in the navbar. -
In the rails console:
# enable feature
Feature.enable(:assign_custom_roles_to_group_links)
# create a member role
member_role = MemberRole.create(base_access_level: 10, name: "Test", admin_cicd_variables: true)
# assign it to group link
GroupGroupLink.last.update(member_role_id: member_role.id)
- While still logged in as
kate
, navigate toGroup A
. You should seeSettings > CI/CD
option in the nav. Same goes for any projects insideGroup A
Related to #443369
Edited by Hinam Mehra