A platform for community discussion. Free, open, simple.
Avoid hardcoding db name in `Upload.migrate_to_new_scheme`.
Guo Xiang Tanc811e5989814
diff --git a/app/models/upload.rb b/app/models/upload.rbindex 303f192465a..202fc570b27 100644--- a/app/models/upload.rb+++ b/app/models/upload.rb@@ -208,8 +208,9 @@ class Upload < ActiveRecord::Baseif SiteSetting.migrate_to_new_schememax_file_size_kb = [SiteSetting.max_image_size_kb, SiteSetting.max_attachment_size_kb].max.kilobyteslocal_store = FileStore::LocalStore.new+ db = RailsMultisite::ConnectionManagement.current_db- scope = Upload.by_users.where("url NOT LIKE '%/original/_X/%' AND url LIKE '%/uploads/#{RailsMultisite::ConnectionManagement.current_db}%'").order(id: :desc)+ scope = Upload.by_users.where("url NOT LIKE '%/original/_X/%' AND url LIKE '%/uploads/#{db}%'").order(id: :desc)scope = scope.limit(limit) if limit@@ -273,7 +274,7 @@ class Upload < ActiveRecord::Baseremap_scope ||= beginPost.with_deleted- .where("raw ~ '/uploads/default/\\d+/'")+ .where("raw ~ '/uploads/#{db}/\\d+/'").select(:raw, :cooked).allend