Skip to content

Draft: POC: use flag_shih_tzu gem for storing permissions for customizable roles

Imre Farkas requested to merge if-poc-flag_shih_tzu into master

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:

  1. introduces flag_shih_tzu gem and bit fields in the MemberRole model
  2. modifies Preloaders::UserMemberRolesInProjectsPreloader to load all customizable permissions (not just download_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 an integer column can store up to 32 flags
    • the same amount of storage can store only 4 boolean column in postgres
  • we can avoid add new migrations for each new customizable permission

Cons:

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.

Edited by Imre Farkas

Merge request reports