PERF: Exclude tables when remapping in migrate_to_s3 rake task.

This commit is contained in:
Guo Xiang Tan 2018-11-08 12:37:36 +08:00
parent 9737938a4a
commit 0232a3b5e5

View File

@ -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 "."