From 82d70912c85e6ebedefb7e133c0e69b17d7d3f57 Mon Sep 17 00:00:00 2001 From: Martin Date: Mon, 25 Mar 2024 15:07:08 +0100 Subject: [PATCH] fix(migration): use strong migration to add fk without validation first, then apply fk validation --- ...0325140537_add_procedure_foreign_key_to_bulk_messages.rb} | 2 +- db/migrate/20240325140538_validate_fk_on_bulk_message.rb | 5 +++++ db/schema.rb | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) rename db/migrate/{20240305170909_add_procedure_foreign_key_to_bulk_messages.rb => 20240325140537_add_procedure_foreign_key_to_bulk_messages.rb} (59%) create mode 100644 db/migrate/20240325140538_validate_fk_on_bulk_message.rb diff --git a/db/migrate/20240305170909_add_procedure_foreign_key_to_bulk_messages.rb b/db/migrate/20240325140537_add_procedure_foreign_key_to_bulk_messages.rb similarity index 59% rename from db/migrate/20240305170909_add_procedure_foreign_key_to_bulk_messages.rb rename to db/migrate/20240325140537_add_procedure_foreign_key_to_bulk_messages.rb index 9872ff071..ed441a8c6 100644 --- a/db/migrate/20240305170909_add_procedure_foreign_key_to_bulk_messages.rb +++ b/db/migrate/20240325140537_add_procedure_foreign_key_to_bulk_messages.rb @@ -1,5 +1,5 @@ class AddProcedureForeignKeyToBulkMessages < ActiveRecord::Migration[7.0] def change - add_foreign_key :bulk_messages, :procedures + add_foreign_key :bulk_messages, :procedures, validate: false end end diff --git a/db/migrate/20240325140538_validate_fk_on_bulk_message.rb b/db/migrate/20240325140538_validate_fk_on_bulk_message.rb new file mode 100644 index 000000000..39c3f805f --- /dev/null +++ b/db/migrate/20240325140538_validate_fk_on_bulk_message.rb @@ -0,0 +1,5 @@ +class ValidateFkOnBulkMessage < ActiveRecord::Migration[7.0] + def change + validate_foreign_key :bulk_messages, :procedures + end +end diff --git a/db/schema.rb b/db/schema.rb index 23792c89d..48b8b7cbf 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1209,6 +1209,7 @@ ActiveRecord::Schema[7.0].define(version: 2024_03_25_160237) do add_foreign_key "avis", "dossiers" add_foreign_key "avis", "experts_procedures" add_foreign_key "batch_operations", "instructeurs" + add_foreign_key "bulk_messages", "procedures" add_foreign_key "bulk_messages_groupe_instructeurs", "bulk_messages" add_foreign_key "bulk_messages_groupe_instructeurs", "groupe_instructeurs" add_foreign_key "champs", "champs", column: "parent_id"