From e68b8f55c2401974de416091e4151c0d60125e05 Mon Sep 17 00:00:00 2001 From: Miha Mencin Date: Wed, 9 Oct 2019 18:00:06 +0200 Subject: [PATCH] skip individual checking --- ...20191009146101_convert_experiments_to_active_storage.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/db/migrate/20191009146101_convert_experiments_to_active_storage.rb b/db/migrate/20191009146101_convert_experiments_to_active_storage.rb index cc03c4595..77be16bc7 100644 --- a/db/migrate/20191009146101_convert_experiments_to_active_storage.rb +++ b/db/migrate/20191009146101_convert_experiments_to_active_storage.rb @@ -30,10 +30,11 @@ class ConvertExperimentsToActiveStorage < ActiveRecord::Migration[5.2] end.compact next if attachments.blank? - - model.find_each.each do |instance| + + model.left_outer_joins(:workflowimg_attachment) + .where('active_storage_attachments.id IS NULL') + .find_each.each do |instance| attachments.each do |attachment| - next if instance.workflowimg.attached? next if instance.__send__("#{attachment}_file_name").blank? res = ActiveRecord::Base.connection.raw_connection.exec_prepared(