From 31902159af8bce27113145833977422c51066c26 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 20 May 2019 17:25:56 +0100 Subject: [PATCH] DEV: Allow skipping failed migrations when running S3 migration Use the SKIP_FAILED environment variable to skip failed sites. Use with caution - make sure you go back and re-run the failed migrations afterwards. --- lib/tasks/uploads.rake | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/tasks/uploads.rake b/lib/tasks/uploads.rake index bab68b134c8..6a30d2322bf 100644 --- a/lib/tasks/uploads.rake +++ b/lib/tasks/uploads.rake @@ -209,7 +209,16 @@ task "uploads:migrate_to_s3" => :environment do end def migrate_to_s3_all_sites - RailsMultisite::ConnectionManagement.each_connection { migrate_to_s3 } + RailsMultisite::ConnectionManagement.each_connection do + begin + migrate_to_s3 + rescue e + if ENV["SKIP_FAILED"] + puts e + else + raise e unless ENV["SKIP_FAILED"] + end + end end def migration_successful?(db, should_raise = false)