mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 13:07:19 +08:00
DEV: Migrate sidebar site settings (#19336)
This new site setting replaces the `enable_experimental_sidebar_hamburger` and `enable_sidebar` site settings as the sidebar feature exits the experimental phase. Note that we're replacing this without depreciation since the previous site setting was considered experimental. Internal Ref: /t/86563
This commit is contained in:

committed by
GitHub

parent
f7f0ca801b
commit
fde9e6bc25
36
db/migrate/20221205225450_migrate_sidebar_site_settings.rb
Normal file
36
db/migrate/20221205225450_migrate_sidebar_site_settings.rb
Normal file
@ -0,0 +1,36 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class MigrateSidebarSiteSettings < ActiveRecord::Migration[7.0]
|
||||
def up
|
||||
previous_enable_experimental_sidebar_hamburger = DB.query_single(
|
||||
"SELECT value FROM site_settings WHERE name = 'enable_experimental_sidebar_hamburger'"
|
||||
)[0]
|
||||
|
||||
previous_enable_sidebar = DB.query_single(
|
||||
"SELECT value FROM site_settings WHERE name = 'enable_sidebar'"
|
||||
)[0]
|
||||
|
||||
value =
|
||||
case [previous_enable_experimental_sidebar_hamburger, previous_enable_sidebar]
|
||||
when ['t', 't'], ['t', nil]
|
||||
"sidebar"
|
||||
when ['t', 'f']
|
||||
"header dropdown"
|
||||
when ['f', 't'], ['f', 'f'], ['f', nil]
|
||||
"legacy"
|
||||
when [nil, 't'], [nil, 'f'], [nil, nil]
|
||||
nil
|
||||
end
|
||||
|
||||
if value
|
||||
execute(<<~SQL)
|
||||
INSERT INTO site_settings (name, data_type, value, created_at, updated_at)
|
||||
VALUES ('navigation_menu', 8, '#{value}', now(), now())
|
||||
SQL
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user