discourse/db/migrate/20220202223955_migrate_selectable_avatars_enabled.rb
Loïc Guitaut 25138db433 DEV: Promote historic post_deploy migrations
This commit promotes all post_deploy migrations which existed in
Discourse v3.0.0 (timestamp <= 20221212234948)
2023-07-26 10:36:37 +02:00

32 lines
925 B
Ruby

# frozen_string_literal: true
class MigrateSelectableAvatarsEnabled < ActiveRecord::Migration[6.1]
def up
execute <<~SQL
UPDATE site_settings AS s
SET value =
CASE WHEN t.value = 't' THEN 'no_one'
ELSE 'disabled'
END,
data_type = #{SiteSettings::TypeSupervisor.types[:enum]},
name = 'selectable_avatars_mode'
FROM site_settings t
WHERE s.id = t.id AND s.name = 'selectable_avatars_enabled'
SQL
end
def down
execute <<~SQL
UPDATE site_settings AS s
SET value =
CASE WHEN t.value IN ('everyone', 'no_one', 'staff', 'tl1','tl2', 'tl3', 'tl4') THEN 't'
ELSE 'f'
END,
data_type = #{SiteSettings::TypeSupervisor.types[:bool]},
name = 'selectable_avatars_enabled'
FROM site_settings t
WHERE s.id = t.id AND s.name = 'selectable_avatars_mode'
SQL
end
end