From 2adbec1b3ca52a5674433698d804d34eceeb0895 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Tue, 7 May 2019 16:08:50 +0800 Subject: [PATCH] PERF: Speed up migrate_to_s3 rake task by deleting optimized image record. No point moving all optimized image files to tombstone when the store is changing. Also, `destroy_all` can easily blow memory since we are no loading in batches. --- lib/tasks/uploads.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/uploads.rake b/lib/tasks/uploads.rake index 8fd1960f224..027351fe3e3 100644 --- a/lib/tasks/uploads.rake +++ b/lib/tasks/uploads.rake @@ -421,7 +421,7 @@ def migrate_to_s3 OptimizedImage .joins("LEFT JOIN uploads u ON optimized_images.upload_id = u.id") .where("u.id IS NOT NULL AND u.url LIKE '//%' AND optimized_images.url NOT LIKE '//%'") - .destroy_all + .delete_all puts "Rebaking posts with lightboxes..."