FIX: close existing polls in closed topics to keep old behaviour
This commit is contained in:
parent
b8929b906c
commit
6c579ba932
|
@ -0,0 +1,18 @@
|
||||||
|
class ClosePollsInClosedTopics < ActiveRecord::Migration
|
||||||
|
|
||||||
|
def up
|
||||||
|
PostCustomField.joins(post: :topic)
|
||||||
|
.where("post_custom_fields.name = 'polls'")
|
||||||
|
.where("topics.closed")
|
||||||
|
.find_each do |pcf|
|
||||||
|
polls = ::JSON.parse(pcf.value || "{}")
|
||||||
|
polls.values.each { |poll| poll["status"] = "closed" }
|
||||||
|
pcf.value = polls.to_json
|
||||||
|
pcf.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in New Issue