Fix active storage migration script (#2060)

* Fix active storage migration script

* Update check logic
This commit is contained in:
aignatov-bio 2019-09-18 09:20:04 +02:00 committed by GitHub
parent 4639d4d1d0
commit 64306cfb2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,6 +25,8 @@ class ConvertToActiveStorage < ActiveRecord::Migration[5.2]
transaction do transaction do
models.each do |model| models.each do |model|
next unless ActiveRecord::Base.connection.table_exists?(model.table_name)
attachments = model.column_names.map do |c| attachments = model.column_names.map do |c|
$1 if c =~ /(.+)_file_name$/ $1 if c =~ /(.+)_file_name$/
end.compact end.compact