From 4e594f2b2bcc22b0fb87c4cfda9ce1517c49ac67 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Thu, 21 Mar 2019 16:40:31 +0800 Subject: [PATCH] FIX: Destroy optimized images in `upload:migrate_to_s3` rake task. `OptimizedImage` are currently not renegerated when the image changes store. --- lib/tasks/uploads.rake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/tasks/uploads.rake b/lib/tasks/uploads.rake index f5f1455e1b..12d16ffed0 100644 --- a/lib/tasks/uploads.rake +++ b/lib/tasks/uploads.rake @@ -378,6 +378,11 @@ def migrate_to_s3 else DbHelper.remap(from, to) end + + 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 end puts "Done!"