From 19105bfd32041c0153e01259fce2ac4cf2096ffe Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Tue, 7 Jan 2025 13:08:36 +1000 Subject: [PATCH] FIX: ChangeFullNameRequiredSetting could fail if setting was already in DB (#30605) Followup 3187606d3402003437c2ccd6121a26f874939228 Fix full_name_requirement INSERT by adding ON CONFLICT DO NOTHING, on sites that already have this setting this migration will fail. --- .../20241224191732_change_full_name_required_setting.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/db/migrate/20241224191732_change_full_name_required_setting.rb b/db/migrate/20241224191732_change_full_name_required_setting.rb index 3475032d468..11471bc9586 100644 --- a/db/migrate/20241224191732_change_full_name_required_setting.rb +++ b/db/migrate/20241224191732_change_full_name_required_setting.rb @@ -20,11 +20,10 @@ 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()) - SQL + 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 def down