mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06: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]
|
class DisableAllowUncategorizedNewSites < ActiveRecord::Migration[7.0]
|
||||||
def up
|
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
|
# 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)
|
INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
|
||||||
VALUES('allow_uncategorized_topics', 5, 't', NOW(), NOW())
|
VALUES('allow_uncategorized_topics', 5, 't', NOW(), NOW())
|
||||||
ON CONFLICT (name) DO NOTHING
|
ON CONFLICT (name) DO NOTHING
|
||||||
|
@ -2,13 +2,6 @@
|
|||||||
|
|
||||||
class MakeExperimentalHashtagFeatureDefaultForNewSites < ActiveRecord::Migration[7.0]
|
class MakeExperimentalHashtagFeatureDefaultForNewSites < ActiveRecord::Migration[7.0]
|
||||||
def up
|
def up
|
||||||
result = execute <<~SQL
|
|
||||||
SELECT created_at
|
|
||||||
FROM schema_migration_details
|
|
||||||
ORDER BY created_at
|
|
||||||
LIMIT 1
|
|
||||||
SQL
|
|
||||||
|
|
||||||
settings_insert_query = <<~SQL
|
settings_insert_query = <<~SQL
|
||||||
INSERT INTO site_settings (name, data_type, value, created_at, updated_at)
|
INSERT INTO site_settings (name, data_type, value, created_at, updated_at)
|
||||||
VALUES ('enable_experimental_hashtag_autocomplete', 5, 'f', now(), now())
|
VALUES ('enable_experimental_hashtag_autocomplete', 5, 'f', now(), now())
|
||||||
@ -16,7 +9,7 @@ class MakeExperimentalHashtagFeatureDefaultForNewSites < ActiveRecord::Migration
|
|||||||
SQL
|
SQL
|
||||||
|
|
||||||
# keep enable_experimental_hashtag_autocomplete disabled for for existing sites
|
# 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
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
|
Loading…
Reference in New Issue
Block a user