mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Convert tl4_delete_posts_and_topics to groups (#24866)
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 tl4_delete_posts_and_topics site setting to delete_all_posts_and_topics_allowed_groups. This one is a bit different from previous ones, as it's a boolean flag, and the default should be no group. Pay special attention to the migration during review.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class FillDeleteAllPostsAndTopicsAllowedGroupsBasedOnDeprecatedSettings < ActiveRecord::Migration[
|
||||
7.0
|
||||
]
|
||||
def up
|
||||
currently_enabled =
|
||||
DB.query_single(
|
||||
"SELECT value FROM site_settings WHERE name = 'tl4_delete_posts_and_topics' AND value = 't' LIMIT 1",
|
||||
).first
|
||||
|
||||
if currently_enabled == "t"
|
||||
# Matches Group::AUTO_GROUPS to the trust levels.
|
||||
tl4 = "14"
|
||||
|
||||
# Data_type 20 is group_list.
|
||||
DB.exec(
|
||||
"INSERT INTO site_settings(name, value, data_type, created_at, updated_at)
|
||||
VALUES('delete_all_posts_and_topics_allowed_groups', :setting, '20', NOW(), NOW())",
|
||||
setting: tl4,
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigrationError
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user