Loading
Add ai_audit_events_storage_enabled cascading setting columns
What does this MR do and why?
Adds the database columns for a new cascading setting, ai_audit_events_storage_enabled, which will gate whether AI audit events are persisted (storage), independently of streaming.
This is the first in a sequence of small MRs for https://gitlab.com/gitlab-org/gitlab/-/work_items/603892. It is columns-only. The model, worker gate, and UI wiring follow in separate MRs, so nothing reads these columns yet.
Two migrations:
add_cascading_namespace_setting :ai_audit_events_storage_enabledadds the value and lock columns toapplication_settings(instance defaulttrue) andnamespace_settings(group level). This reuses the same cascading-setting helper as the existingrequire_sha_for_mergesetting.- A second migration adds the project-level leaf column to
project_settings.
Resulting columns:
| Table | Column | Null | Default |
|---|---|---|---|
application_settings |
ai_audit_events_storage_enabled |
not null | true |
application_settings |
lock_ai_audit_events_storage_enabled |
not null | false |
namespace_settings |
ai_audit_events_storage_enabled |
null | |
namespace_settings |
lock_ai_audit_events_storage_enabled |
not null | false |
project_settings |
ai_audit_events_storage_enabled |
null |
References
- Migration work item: https://gitlab.com/gitlab-org/gitlab/-/work_items/604013
- Parent: https://gitlab.com/gitlab-org/gitlab/-/work_items/603892
Database
Both directions were run against a development database.
Up:
== 20260624201545 AddAiAuditEventsStorageEnabledCascadingSetting: migrating ===
-- add_column(:namespace_settings, :ai_audit_events_storage_enabled, :boolean, {:default=>nil, :null=>true})
-- add_column(:namespace_settings, :lock_ai_audit_events_storage_enabled, :boolean, {:default=>false, :null=>false})
-- add_column(:application_settings, :ai_audit_events_storage_enabled, :boolean, {:default=>true, :null=>false})
-- add_column(:application_settings, :lock_ai_audit_events_storage_enabled, :boolean, {:default=>false, :null=>false})
== 20260624201545 AddAiAuditEventsStorageEnabledCascadingSetting: migrated (0.4853s)
== 20260624201546 AddAiAuditEventsStorageEnabledToProjectSettings: migrating ==
-- add_column(:project_settings, :ai_audit_events_storage_enabled, :boolean)
== 20260624201546 AddAiAuditEventsStorageEnabledToProjectSettings: migrated (0.0075s)Down:
== 20260624201546 AddAiAuditEventsStorageEnabledToProjectSettings: reverting ==
-- remove_column(:project_settings, :ai_audit_events_storage_enabled, :boolean)
== 20260624201546 AddAiAuditEventsStorageEnabledToProjectSettings: reverted (0.0652s)
== 20260624201545 AddAiAuditEventsStorageEnabledCascadingSetting: reverting ===
-- remove_column(:namespace_settings, :ai_audit_events_storage_enabled)
-- remove_column(:namespace_settings, :lock_ai_audit_events_storage_enabled)
-- remove_column(:application_settings, :ai_audit_events_storage_enabled)
-- remove_column(:application_settings, :lock_ai_audit_events_storage_enabled)
== 20260624201545 AddAiAuditEventsStorageEnabledCascadingSetting: reverted (0.4759s)How to set up and validate locally
- Run the migrations:
bin/rails db:migrate:main - Confirm the columns exist with the expected defaults:
%w[application_settings namespace_settings project_settings].each do |t| cols = ApplicationRecord.connection.columns(t).select { |c| c.name.include?('ai_audit_events_storage_enabled') } cols.each { |c| puts "#{t}.#{c.name} null=#{c.null} default=#{c.default.inspect}" } end - Confirm reversibility:
bin/rails db:migrate:down:main VERSION=20260624201546 bin/rails db:migrate:down:main VERSION=20260624201545
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.