mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 01:13:38 +08:00
DEV: Use Migration::Helpers.existing_site? for other migrations (#20949)
Followup to f3402be262
, adds
the new helper to two other core migrations that need it.
This commit is contained in:
parent
62696b9ee7
commit
6b9dd22ba7
|
@ -2,15 +2,8 @@
|
|||
|
||||
class DisableAllowUncategorizedNewSites < ActiveRecord::Migration[7.0]
|
||||
def up
|
||||
result = execute <<~SQL
|
||||
SELECT created_at
|
||||
FROM schema_migration_details
|
||||
ORDER BY created_at
|
||||
LIMIT 1
|
||||
SQL
|
||||
|
||||
# keep allow uncategorized for existing sites
|
||||
execute <<~SQL if result.first["created_at"].to_datetime < 1.hour.ago
|
||||
execute <<~SQL if Migration::Helpers.existing_site?
|
||||
INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
|
||||
VALUES('allow_uncategorized_topics', 5, 't', NOW(), NOW())
|
||||
ON CONFLICT (name) DO NOTHING
|
||||
|
|
|
@ -2,13 +2,6 @@
|
|||
|
||||
class MakeExperimentalHashtagFeatureDefaultForNewSites < ActiveRecord::Migration[7.0]
|
||||
def up
|
||||
result = execute <<~SQL
|
||||
SELECT created_at
|
||||
FROM schema_migration_details
|
||||
ORDER BY created_at
|
||||
LIMIT 1
|
||||
SQL
|
||||
|
||||
settings_insert_query = <<~SQL
|
||||
INSERT INTO site_settings (name, data_type, value, created_at, updated_at)
|
||||
VALUES ('enable_experimental_hashtag_autocomplete', 5, 'f', now(), now())
|
||||
|
@ -16,7 +9,7 @@ class MakeExperimentalHashtagFeatureDefaultForNewSites < ActiveRecord::Migration
|
|||
SQL
|
||||
|
||||
# keep enable_experimental_hashtag_autocomplete disabled for for existing sites
|
||||
execute settings_insert_query if result.first["created_at"].to_datetime < 1.hour.ago
|
||||
execute settings_insert_query if Migration::Helpers.existing_site?
|
||||
end
|
||||
|
||||
def down
|
||||
|
|
Loading…
Reference in New Issue
Block a user