Merge pull request #9134 from colinux/migrate-dossier-corrections-multiple-transactions

ETQ dev fix création des foreign keys de la création de la table `dossier_corrections`
This commit is contained in:
Colin Darie 2023-06-05 12:21:36 +00:00 committed by GitHub
commit 08154d46d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View file

@ -3,8 +3,10 @@ class CreateDossierCorrections < ActiveRecord::Migration[6.1]
def change def change
create_table :dossier_corrections do |t| create_table :dossier_corrections do |t|
t.references :dossier, null: false, foreign_key: true # foreign keys are added in a later migration
t.references :commentaire, foreign_key: true # see https://github.com/fatkodima/online_migrations#adding-multiple-foreign-keys
t.references :dossier, null: false, foreign_key: false
t.references :commentaire, foreign_key: false
t.datetime :resolved_at, precision: 6 t.datetime :resolved_at, precision: 6
t.timestamps t.timestamps

View file

@ -0,0 +1,11 @@
class AddForeignKeysToDossierCorrections < ActiveRecord::Migration[7.0]
disable_ddl_transaction!
def change
add_foreign_key :dossier_corrections, :dossiers, column: :dossier_id, validate: false
validate_foreign_key :dossier_corrections, :dossiers
add_foreign_key :dossier_corrections, :commentaires, column: :commentaire_id, validate: false
validate_foreign_key :dossier_corrections, :commentaires
end
end