[default branch protection] write to the new jsonb settings column from existing API
Background Context
Currently, the options for default branch protection at the instance and group level lag behind, and are not as fin grained, as the options available from the Protected Branches feature
The branch defaults lag behind because the current implementation uses an integer column to store the default settings, which becomes difficult if not impossible to expand as new options and finer detail controls are added to the protected branches feature
at a high-ish level the existing feature is implemented as:
- there are integer columns on the database tables (application level and group level)
- these integers are mapped to a subset of protected branch settings
- these mappings defined in access.rb
- mappings are used here via
BranchProtection
helper
- when creating a default branch, those settings are passed into the protected branch service
Proposal
A more detailed proposal can be seen in the epic [here](&10391
At a high level the proposal is to:
- use a
jsonb
column rather than an integer - update the settings API to accept a payload the matches the protected branches API
- Pass those settings into the
ProtecteBrancheService
here
This issue
In #408150 (closed), we added a new jsonb
column that will eventually be used to store the default branch protection settings.
Eventually, the API will be updated to allow updating of the column directly (#408151 (closed)) and the existing default_branch_protection
API will need to be deprecated
Before that time comes, we want to update the existing default_branch_protection
API implementation to update the new jsonb
column in addition to the column it is already writing to.
This is prep work to make the switch from using the existing implementation to the new column as seamless to the end-user as we can when the time comes, and prevents us from having null
values in that column.
Alternatively, we could skip this work and at read-time do some logic such as:
- if new
jsonb
column isnull
, fall back to the originaldefault_branch_protection
logic