discourse/db/migrate/20250724012518_drop_horizon_setting_field.rb
Martin Brennan 57fea290ef
DEV: Use themeable site settings for Horizon (#33645)
This commit removes the value transformers introduced
to Horizon back in
274e5f7a1f
and
897d34132e
in favor of the new themeable site settings introduced in
19af83d39e , as this is what they
are for.

No migration for existing sites...they will already have
ThemeSiteSetting values from a previous migration to ensure
site setting values were preserved in theme site settings.

We do delete the ThemeField storing the Horizon custom theme
setting definition though, otherwise the UI still shows the old
settings.
2025-07-24 12:20:34 +10:00

27 lines
705 B
Ruby

# frozen_string_literal: true
class DropHorizonSettingField < ActiveRecord::Migration[8.0]
def up
old_setting_field_id = DB.query_single(<<~SQL).first
SELECT id FROM theme_fields
WHERE theme_id = -2 AND name = 'yaml' AND target_id = 3
SQL
return if old_setting_field_id.nil?
# target_id 3 is Theme.targets[:settings]
# ID -2 is always the Horizon theme since it's a core theme
DB.exec(<<~SQL)
DELETE FROM theme_fields
WHERE id = #{old_setting_field_id}
SQL
DB.exec(<<~SQL)
DELETE FROM javascript_caches
WHERE theme_field_id = #{old_setting_field_id}
SQL
end
def down
raise ActiveRecord::IrreversibleMigration
end
end