mirror of
https://github.com/discourse/discourse.git
synced 2025-03-28 17:25:44 +08:00
FIX: properly migrate polls/votes stored as array
This commit is contained in:
parent
a3ed570124
commit
ed400a90fe
@ -58,6 +58,10 @@ class MigratePollsData < ActiveRecord::Migration[5.2]
|
|||||||
SQL
|
SQL
|
||||||
|
|
||||||
DB.query(sql).each do |r|
|
DB.query(sql).each do |r|
|
||||||
|
# for some reasons, polls or votes might be an array
|
||||||
|
r.polls = r.polls[0] if Array === r.polls && r.polls.size > 0
|
||||||
|
r.votes = r.votes[0] if Array === r.votes && r.votes.size > 0
|
||||||
|
|
||||||
existing_user_ids = User.where(id: r.votes.keys).pluck(:id).to_set
|
existing_user_ids = User.where(id: r.votes.keys).pluck(:id).to_set
|
||||||
|
|
||||||
# Poll votes are stored in a JSON object with the following hierarchy
|
# Poll votes are stored in a JSON object with the following hierarchy
|
||||||
|
Loading…
x
Reference in New Issue
Block a user