Skip to content

Commit 012b48d

Browse files
authored
DEV: Migrate add-groups-to-about component settings to site settings (#32910)
We're moving the add-groups-to-about theme component into core. We have already added the logic and switchover in #32659. This PR adds a data migration that maps the theme settings to the relevant site settings, then enables the core implementation.
1 parent 1c1300d commit 012b48d

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# frozen_string_literal: true
2+
3+
class CopyAddGroupsToAboutComponentSettings < ActiveRecord::Migration[7.2]
4+
MAPPING = {
5+
"about_groups" => "about_page_extra_groups",
6+
"order_additional_groups" => "about_page_extra_groups_order",
7+
"show_group_description" => "about_page_extra_groups_show_description",
8+
"show_initial_members" => "about_page_extra_groups_initial_members",
9+
}
10+
11+
def up
12+
theme_settings = execute(<<~SQL).to_a
13+
SELECT name, value
14+
FROM theme_settings
15+
WHERE theme_id = (
16+
SELECT id
17+
FROM themes
18+
WHERE name = 'Add Groups to About'
19+
AND enabled = true
20+
)
21+
SQL
22+
23+
return if theme_settings.blank?
24+
25+
theme_settings.each do |theme_setting|
26+
site_setting = MAPPING[theme_setting["name"]]
27+
28+
next if !site_setting
29+
30+
SiteSetting.set(MAPPING[theme_setting["name"]], theme_setting["value"])
31+
end
32+
33+
SiteSetting.set("show_additional_about_groups", true)
34+
end
35+
36+
def down
37+
raise ActiveRecord::IrreversibleMigration
38+
end
39+
end

0 commit comments

Comments
 (0)