mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 11:53:55 +08:00
f3402be262
We use schema_migration_details to determine the age of a site in multiple migrations. This commit moves the logic into a dedicated `Migration::Helpers` module so that it doesn't need to be re-implemented every time.
24 lines
700 B
Ruby
24 lines
700 B
Ruby
# frozen_string_literal: true
|
|
|
|
class EnableSidebarAndChat < ActiveRecord::Migration[7.0]
|
|
def up
|
|
# keep sidebar legacy and chat disabled for existing sites
|
|
if Migration::Helpers.existing_site?
|
|
execute <<~SQL
|
|
INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
|
|
VALUES('chat_enabled', 5, 'f', NOW(), NOW())
|
|
ON CONFLICT (name) DO NOTHING
|
|
SQL
|
|
execute <<~SQL
|
|
INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
|
|
VALUES('navigation_menu', 7, 'legacy', NOW(), NOW())
|
|
ON CONFLICT (name) DO NOTHING
|
|
SQL
|
|
end
|
|
end
|
|
|
|
def down
|
|
raise ActiveRecord::IrreversibleMigration
|
|
end
|
|
end
|