mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 22:26:26 +08:00
Use update_all instead of save to select and update particular columns
9ec6ef85b6
This commit is contained in:
parent
4a03b21f80
commit
84cfe30c1f
|
@ -294,14 +294,14 @@ class Upload < ActiveRecord::Base
|
|||
remap_scope ||= begin
|
||||
Post.with_deleted
|
||||
.where("raw ~ '/uploads/#{db}/\\d+/' OR raw ~ '/uploads/#{db}/original/(\\d|[a-z])/'")
|
||||
.select(:raw, :cooked)
|
||||
.select(:id, :raw, :cooked)
|
||||
.all
|
||||
end
|
||||
|
||||
remap_scope.each do |post|
|
||||
post.raw.gsub!(previous_url, upload.url)
|
||||
post.cooked.gsub!(previous_url, upload.url)
|
||||
post.save!(validate: false) if post.changed?
|
||||
Post.with_deleted.where(id: post.id).update_all(raw: post.raw, cooked: post.cooked) if post.changed?
|
||||
end
|
||||
|
||||
upload.optimized_images.find_each(&:destroy!)
|
||||
|
|
Loading…
Reference in New Issue
Block a user