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:
Martin Brennan 2023-04-05 09:28:56 +10:00 committed by GitHub
parent 62696b9ee7
commit 6b9dd22ba7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 16 deletions

View File

@ -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

View File

@ -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