mirror of
https://github.com/discourse/discourse.git
synced 2025-06-07 08:47:15 +08:00
PERF: Exclude tables when remapping in migrate_to_s3
rake task.
This commit is contained in:
@ -226,6 +226,14 @@ def migrate_to_s3
|
|||||||
s3 = FileStore::S3Store.new
|
s3 = FileStore::S3Store.new
|
||||||
local = FileStore::LocalStore.new
|
local = FileStore::LocalStore.new
|
||||||
|
|
||||||
|
exclude_tables = %i{
|
||||||
|
incoming_emails
|
||||||
|
stylesheet_cache
|
||||||
|
search_logs
|
||||||
|
post_search_data
|
||||||
|
notifications
|
||||||
|
}
|
||||||
|
|
||||||
# Migrate all uploads
|
# Migrate all uploads
|
||||||
Upload.where.not(sha1: nil)
|
Upload.where.not(sha1: nil)
|
||||||
.where("url NOT LIKE '#{s3.absolute_base_url}%'")
|
.where("url NOT LIKE '#{s3.absolute_base_url}%'")
|
||||||
@ -257,9 +265,14 @@ def migrate_to_s3
|
|||||||
end
|
end
|
||||||
|
|
||||||
# remap the URL
|
# 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))
|
[UrlHelper.absolute(from), Discourse.store.cdn_url(to)],
|
||||||
DbHelper.remap(from, 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
|
upload.optimized_images.destroy_all
|
||||||
|
|
||||||
putc "."
|
putc "."
|
||||||
|
Reference in New Issue
Block a user