Skip to content

Draft: Render custom role assigned to author when rendering notes

What does this MR do and why?

  • This MR adds member_role_id to the ProjectAuthorizations table.
  • It also updates the human_max_access method so a user's custom role is displayed next to their comments.
  • This MR is just step 1. In follow up MRs, I will update the methods & create a batched background migration to populate the member_role_id column in the ProjectAuthorizationsTable from the Member table.

Database

Output of db:migrate
main: == 20240910055335 AddMemberRoleIdToProjectAuthorizations: migrating ===========
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- add_column(:project_authorizations, :member_role_id, :bigint)
main:    -> 0.0017s
main: == 20240910055335 AddMemberRoleIdToProjectAuthorizations: migrated (0.0129s) ==

main: == 20240917062210 AddFkToMemberRoleOnProjectAuthorizations: migrating =========
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- execute("ALTER TABLE project_authorizations ADD CONSTRAINT fk_88a59c7b2d FOREIGN KEY (member_role_id) REFERENCES member_roles (id) ON DELETE SET NULL NOT VALID;")
main:    -> 0.0020s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0004s
main: -- execute("ALTER TABLE project_authorizations VALIDATE CONSTRAINT fk_88a59c7b2d;")
main:    -> 0.0014s
main: -- execute("RESET statement_timeout")
main:    -> 0.0005s
main: == 20240917062210 AddFkToMemberRoleOnProjectAuthorizations: migrated (0.0737s) 
Output of db:rollback
main: == 20240910055335 AddMemberRoleIdToProjectAuthorizations: reverting ===========
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- remove_column(:project_authorizations, :member_role_id)
main:    -> 0.0012s
main: == 20240910055335 AddMemberRoleIdToProjectAuthorizations: reverted (0.0209s) ==

main: == 20240917062210 AddFkToMemberRoleOnProjectAuthorizations: reverting =========
main: -- transaction_open?(nil)
main:    -> 0.0000s
main: -- remove_foreign_key(:project_authorizations, {:column=>:member_role_id})
main:    -> 0.0390s
main: == 20240917062210 AddFkToMemberRoleOnProjectAuthorizations: reverted (0.0617s) 

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

Before After
Screenshot_2024-09-17_at_5.03.42_PM Screenshot_2024-09-17_at_5.09.35_PM

How to set up and validate locally

Related to #464338

Edited by Hinam Mehra

Merge request reports

Loading