diff options
Diffstat (limited to 'activestorage')
-rw-r--r-- | activestorage/db/update_migrate/20180723000244_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.rb | 7 | ||||
-rw-r--r-- | activestorage/lib/tasks/activestorage.rake | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/activestorage/db/update_migrate/20180723000244_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.rb b/activestorage/db/update_migrate/20180723000244_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.rb new file mode 100644 index 0000000000..6830203cd6 --- /dev/null +++ b/activestorage/db/update_migrate/20180723000244_add_foreign_key_constraint_to_active_storage_attachments_for_blob_id.rb @@ -0,0 +1,7 @@ +class AddForeignKeyConstraintToActiveStorageAttachmentsForBlobId < ActiveRecord::Migration[6.0] + def up + unless foreign_key_exists?(:active_storage_attachments, column: :blob_id) + add_foreign_key :active_storage_attachments, :active_storage_blobs, column: :blob_id + end + end +end diff --git a/activestorage/lib/tasks/activestorage.rake b/activestorage/lib/tasks/activestorage.rake index ac254d717f..6b0469636c 100644 --- a/activestorage/lib/tasks/activestorage.rake +++ b/activestorage/lib/tasks/activestorage.rake @@ -12,4 +12,11 @@ namespace :active_storage do Rake::Task["app:active_storage:install:migrations"].invoke end end + + # desc "Copy over the migrations needed to the application upgrading" + task update: :environment do + ENV["MIGRATIONS_PATH"] = "db/update_migrate" + + Rake::Task["active_storage:install"].invoke + end end |