FIX: ChangeFullNameRequiredSetting could fail if setting was already in DB (#30605)

Followup 3187606d34

Fix full_name_requirement INSERT by adding ON CONFLICT DO NOTHING,
on sites that already have this setting this migration will fail.
This commit is contained in:
Martin Brennan 2025-01-07 13:08:36 +10:00 committed by GitHub
parent 51a444ab53
commit 19105bfd32
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -20,10 +20,9 @@ class ChangeFullNameRequiredSetting < ActiveRecord::Migration[7.2]
SQL
DB.exec(<<~SQL, value: new_setting) if new_setting
INSERT INTO site_settings
(name, data_type, value, created_at, updated_at)
VALUES
('full_name_requirement', 7, :value, NOW(), NOW())
INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
VALUES ('full_name_requirement', 7, :value, NOW(), NOW())
ON CONFLICT (name) DO NOTHING
SQL
end