mirror of
https://github.com/discourse/discourse.git
synced 2024-12-24 23:26:27 +08:00
234133bd3b
It splits the hide_profile_and_presence user option and the default_hide_profile_and_presence site setting for more granular control. It keeps the option to hide the profile under /u/username/preferences/interface and adds the presence toggle in the quick user menu. Co-authored-by: Régis Hanol <regis@hanol.fr>
39 lines
1.3 KiB
Ruby
39 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class SplitHideProfileAndPresence < ActiveRecord::Migration[7.1]
|
|
def up
|
|
# Split default_hide_profile_and_presence if setting exists
|
|
result =
|
|
execute(
|
|
"SELECT value, data_type FROM site_settings WHERE name = 'default_hide_profile_and_presence' LIMIT 1",
|
|
).first
|
|
|
|
if result
|
|
value = result["value"]
|
|
data_type = result["data_type"]
|
|
|
|
execute "DELETE FROM site_settings WHERE name = 'default_hide_profile_and_presence'"
|
|
execute <<-SQL
|
|
INSERT INTO site_settings (name, value, data_type, created_at, updated_at)
|
|
VALUES
|
|
('default_hide_profile', '#{value}', '#{data_type}', NOW(), NOW()),
|
|
('default_hide_presence', '#{value}', '#{data_type}', NOW(), NOW());
|
|
SQL
|
|
end
|
|
|
|
# Add new columns to user_options
|
|
execute "ALTER TABLE user_options ADD COLUMN hide_profile BOOLEAN DEFAULT FALSE NOT NULL"
|
|
execute "ALTER TABLE user_options ADD COLUMN hide_presence BOOLEAN DEFAULT FALSE NOT NULL"
|
|
execute <<-SQL
|
|
UPDATE user_options
|
|
SET hide_profile = hide_profile_and_presence,
|
|
hide_presence = hide_profile_and_presence
|
|
WHERE hide_profile_and_presence;
|
|
SQL
|
|
end
|
|
|
|
def down
|
|
raise ActiveRecord::IrreversibleMigration
|
|
end
|
|
end
|