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_defaults JSONB 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: ... to ApplicationSetting, with a new application_setting_project_defaults.json schema. The schema is an empty object with additionalProperties: 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:

  1. This MR: database foundation
  2. 465720-default-remove-source-branch-setting
  3. 465720-default-remove-source-branch-admin-ui

How to set up and validate locally

  1. Run the database migration checks in CI.

  2. Verify that application_settings.project_defaults is a non-null JSONB object with the expected check constraint.

  3. 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

Merge request reports

Loading
Loading