DEV: Move min_trust_to_post_embedded_media to group setting (#25238)

c.f. https://meta.discourse.org/t/we-are-changing-giving-access-to-features/283408
This commit is contained in:
Martin Brennan
2024-01-25 09:50:59 +10:00
committed by GitHub
parent cf25fab9b0
commit 0e50f88212
22 changed files with 374 additions and 171 deletions

View File

@@ -0,0 +1,24 @@
# frozen_string_literal: true
class FillEmbeddedMediaPostAllowedGroupsBasedOnDeprecatedSetting < ActiveRecord::Migration[7.0]
def up
old_setting_trust_level =
DB.query_single(
"SELECT value FROM site_settings WHERE name = 'min_trust_to_post_embedded_media' LIMIT 1",
).first
if old_setting_trust_level.present?
allowed_groups = "1#{old_setting_trust_level}"
DB.exec(
"INSERT INTO site_settings(name, value, data_type, created_at, updated_at)
VALUES('embedded_media_post_allowed_groups', :setting, '20', NOW(), NOW())",
setting: allowed_groups,
)
end
end
def down
raise ActiveRecord::IrreversibleMigration
end
end