Draft: POC: use flag_shih_tzu gem for storing permissions for customizable roles
What does this MR do and why?
This a proof of concept to evaluate to use of flag_shih_tzu
gem as suggested in #352891 (comment 1059561579).
Customizable roles currently support a single permission: download_code
. However, we plan on making most of our permissions defined in the policies files customizable. As a result, MemberRole
model will have lot's of boolean
columns. flag_shih_tzu
allows the use of ActiveRecord
bit fields. It helps reducing the number of columns
This POC tries to achieve 2 goals:
- introduces
flag_shih_tzu
gem and bit fields in theMemberRole
model - modifies
Preloaders::UserMemberRolesInProjectsPreloader
to load all customizable permissions (not justdownload_code
), and calculates the resulting effective permissions based on them
Pros and cons of the gem
Pros:
- optimized storage use
- with
flag_shih_tzu
, using aninteger
column can store up to 32 flags - the same amount of storage can store only 4
boolean
column inpostgres
- with
- we can avoid add new migrations for each new customizable permission
Cons:
- the gem does not meet the quality standards for external libraries
- adds an additional layer of logic to manage
integer
column as bit field
Related to #375575 (closed).
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.