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/20250709051949_disable_gravatar_enabled_if_unconfigured.rb
Ted Johansson 3604aa2bcc
DEV: Add a Gravatar enable/disable toggle (#33533)
We want to add the ability to enable/disable users selecting Gravatar for their avatar.

This change adds a site setting to enable/disable the option (default to enabled.) This will prevent users from configuring Gravatars from that point on. It does not affect already configured avatars.

We're also taking this chance to hide some of the advanced settings from the UI.
2025-07-10 15:09:32 +08:00

24 lines
578 B
Ruby

# frozen_string_literal: true
class DisableGravatarEnabledIfUnconfigured < ActiveRecord::Migration[7.2]
def up
execute <<~SQL
INSERT INTO site_settings (name, data_type, value, created_at, updated_at)
SELECT 'gravatar_enabled', 5, 'f', 'NOW()', 'NOW()'
WHERE EXISTS (
SELECT 1
FROM site_settings
WHERE name = 'gravatar_base_url' AND (
VALUE = '' OR
VALUE IS NULL
)
LIMIT 1
)
ON CONFLICT DO NOTHING;
SQL
end
def down
raise ActiveRecord::IrreversibleMigration
end
end