You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
654 B
24 lines
654 B
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
|