mirror of
https://github.com/discourse/discourse.git
synced 2025-03-21 03:28:54 +08:00
fix MergePollsVotes migration
This commit is contained in:
parent
14bfeec25e
commit
131e7ed445
@ -5,11 +5,11 @@ class MergePollsVotes < ActiveRecord::Migration
|
|||||||
polls_votes = {}
|
polls_votes = {}
|
||||||
PostCustomField.where(post_id: post_id).where("name LIKE 'polls-votes-%'").find_each do |pcf|
|
PostCustomField.where(post_id: post_id).where("name LIKE 'polls-votes-%'").find_each do |pcf|
|
||||||
user_id = pcf.name["polls-votes-".size..-1]
|
user_id = pcf.name["polls-votes-".size..-1]
|
||||||
polls_votes["#{user_id}"] = ::JSON.parse(pcf.value)
|
polls_votes["#{user_id}"] = ::JSON.parse(pcf.value||"{}")
|
||||||
end
|
end
|
||||||
|
|
||||||
pcf = PostCustomField.find_or_create_by(name: "polls-votes", post_id: post_id)
|
pcf = PostCustomField.find_or_create_by(name: "polls-votes", post_id: post_id)
|
||||||
pcf.value = ::JSON.parse(pcf.value).merge(polls_votes).to_json
|
pcf.value = ::JSON.parse(pcf.value||"{}").merge(polls_votes).to_json
|
||||||
pcf.save
|
pcf.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user