DEV: Convert min_trust_to_allow_self_wiki to groups (#25009)

We're changing the implementation of trust levels to use groups. Part of this is to have site settings that reference trust levels use groups instead. It converts the min_trust_to_allow_self_wiki site setting to self_wiki_allowed_groups.

Nothing of note here. This is used in exactly one place, and there's no fallout.
This commit is contained in:
Ted Johansson
2023-12-27 09:21:39 +08:00
committed by GitHub
parent 3c818ff07e
commit b890eb1bd2
6 changed files with 39 additions and 3 deletions

View File

@@ -0,0 +1,26 @@
# frozen_string_literal: true
class FillSelfWikiAllowedGroupsBasedOnDeprecatedSettings < ActiveRecord::Migration[7.0]
def up
configured_trust_level =
DB.query_single(
"SELECT value FROM site_settings WHERE name = 'min_trust_to_allow_self_wiki' LIMIT 1",
).first
# Default for old setting is TL3, we only need to do anything if it's been changed in the DB.
if configured_trust_level.present?
corresponding_group = "1#{configured_trust_level}"
# Data_type 20 is group_list.
DB.exec(
"INSERT INTO site_settings(name, value, data_type, created_at, updated_at)
VALUES('self_wiki_allowed_groups', :setting, '20', NOW(), NOW())",
setting: corresponding_group,
)
end
end
def down
raise ActiveRecord::IrreversibleMigration
end
end