correctif(data): ajoute la clé etrangère entre active_storage_attachements et active_storage_blobs uniquement si elle est manquante

This commit is contained in:
Martin 2023-03-02 08:34:17 +01:00
parent 899bb73ce8
commit b0376ec99c

View file

@ -1,5 +1,7 @@
class FixActiveStorageAttachmentMissingFkOnBlobId < ActiveRecord::Migration[6.1]
def change
add_foreign_key :active_storage_attachments, :active_storage_blobs, column: :blob_id, validate: false
if !foreign_key_exists?(:active_storage_attachments, :active_storage_blobs, column: :blob_id)
add_foreign_key :active_storage_attachments, :active_storage_blobs, column: :blob_id, validate: false
end
end
end