2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-03-03 23:54:20 +08:00
discourse/db/post_migrate/20250702082232_deprecate_external_system_avatars_enabled.rb
Ted Johansson 4c7089f817
DEV: Deprecate external_system_avatars_enabled (#33436)
We want to deprecate the enabled/disabled toggle for this setting and rely entirely on the presence of a URL.

This change:

- Deprecates and hides the enabled/disabled setting.
- Updates all code paths and tests that rely on the old setting.
- Adds a migration that clears the URL if the enabled/disabled setting is set to false.
2025-07-04 16:02:04 +08:00

21 lines
617 B
Ruby

# frozen_string_literal: true
class DeprecateExternalSystemAvatarsEnabled < ActiveRecord::Migration[7.2]
def up
execute <<~SQL
INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
SELECT 'external_system_avatars_url', 1, '', 'NOW()', 'NOW()'
WHERE EXISTS (
SELECT 1
FROM site_settings
WHERE name = 'external_system_avatars_enabled'
AND value = 'f'
)
ON CONFLICT(name) DO UPDATE
SET value = EXCLUDED.value, updated_at = EXCLUDED.updated_at;
SQL
end
def down
raise ActiveRecord::IrreversibleMigration
end
end