commit
a945aa0cd2
@ -0,0 +1,23 @@
|
|||||||
|
class MigrateBankQuotes < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
HomeworkBank.all.each do |bank|
|
||||||
|
bank.update_column("quotes", bank.homework_commons.count)
|
||||||
|
end
|
||||||
|
|
||||||
|
GtopicBank.all.each do |bank|
|
||||||
|
bank.update_column("quotes", bank.graduation_topics.count)
|
||||||
|
end
|
||||||
|
|
||||||
|
GtaskBank.all.each do |bank|
|
||||||
|
bank.update_column("quotes", bank.graduation_tasks.count)
|
||||||
|
end
|
||||||
|
|
||||||
|
ExerciseBank.all.each do |bank|
|
||||||
|
if bank.container_type == 'Exercise'
|
||||||
|
bank.update_column("quotes", bank.exercises.count)
|
||||||
|
elsif bank.container_type == 'Poll'
|
||||||
|
bank.update_column("quotes", bank.polls.count)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in new issue