mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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:
@@ -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
|
||||
Reference in New Issue
Block a user