FEATURE: make the use_email_for_username_and_name_suggestions setting visible and on by default on existing sites (#15751)

This commit is contained in:
Andrei Prigorshnev
2022-02-01 11:55:17 +01:00
committed by GitHub
parent c46b55dc3b
commit dad2e5e513
3 changed files with 26 additions and 1 deletions

View File

@@ -0,0 +1,25 @@
# frozen_string_literal: true
class SetUseEmailForUsernameAndNameSuggestionsOnExistingSites < ActiveRecord::Migration[6.1]
def up
result = execute <<~SQL
SELECT created_at
FROM schema_migration_details
ORDER BY created_at
LIMIT 1
SQL
# make setting enabled for existing sites
if result.first['created_at'].to_datetime < 1.hour.ago
execute <<~SQL
INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
VALUES('use_email_for_username_and_name_suggestions', 5, 't', NOW(), NOW())
ON CONFLICT (name) DO NOTHING
SQL
end
end
def down
raise ActiveRecord::IrreversibleMigration
end
end