Loading
Add project defaults to application settings
What does this MR do and why?
Contributes to #465720 (closed)
Problem
Application settings do not have a structured place for defaults that apply when new projects are created.
Solution
- Add the
project_defaultsJSONB column to application settings. - Add the column metadata and a database check constraint that keeps the value a JSON object.
- Add
validates :project_defaults, json_schema: ...toApplicationSetting, with a newapplication_setting_project_defaults.jsonschema. The schema is an empty object withadditionalProperties: false, so only{}is valid for now. Follow-up MRs add properties to it. - Update
db/structure.sql.
Why the validator is in this MR
The JSON schema validator was originally planned for !260680 (merged), but adding the JSONB column without it blocked this MR. The validator moved here so the column and its validation land together. The schema allows no keys yet, so this does not change behavior.
References
Relates to #465720 (closed)
Stack order:
- This MR: database foundation
465720-default-remove-source-branch-setting465720-default-remove-source-branch-admin-ui
How to set up and validate locally
-
Run the database migration checks in CI.
-
Verify that
application_settings.project_defaultsis a non-null JSONB object with the expected check constraint. -
In a Rails console, verify that only an empty hash is valid:
setting = ApplicationSetting.current setting.project_defaults = { 'foo' => 'bar' } setting.valid? # => false
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist.
Edited by Vasilii Iakliushin