Skip to content

A platform for community discussion. Free, open, simple.

PERF: Exclude tables when remapping in `migrate_to_s3` rake task.

Guo Xiang Tan0232a3b5e548
diff --git a/lib/tasks/uploads.rake b/lib/tasks/uploads.rake
index 91d8916a3db..a008c72d5b8 100644
--- a/lib/tasks/uploads.rake
+++ b/lib/tasks/uploads.rake
@@ -226,6 +226,14 @@ def migrate_to_s3
s3 = FileStore::S3Store.new
local = FileStore::LocalStore.new
+ exclude_tables = %i{
+ incoming_emails
+ stylesheet_cache
+ search_logs
+ post_search_data
+ notifications
+ }
+
# Migrate all uploads
Upload.where.not(sha1: nil)
.where("url NOT LIKE '#{s3.absolute_base_url}%'")
@@ -257,9 +265,14 @@ def migrate_to_s3
end
# remap the URL
- DbHelper.remap(UrlHelper.absolute(from), Discourse.store.cdn_url(to))
- DbHelper.remap(UrlHelper.absolute_without_cdn(from), Discourse.store.cdn_url(to))
- DbHelper.remap(from, to)
+ [
+ [UrlHelper.absolute(from), Discourse.store.cdn_url(to)],
+ [UrlHelper.absolute_without_cdn(from), Discourse.store.cdn_url(to)],
+ [from, to],
+ ].each do |from_url, to_url|
+ DbHelper.remap(from_url, to_url, exclude_tables: exclude_tables)
+ end
+
upload.optimized_images.destroy_all
putc "."