socialforge/db/migrate/20150911031029_about_progra...

26 lines
893 B
Ruby
Raw Normal View History

2015-09-11 11:31:59 +08:00
class AboutProgramingHomework < ActiveRecord::Migration
def up
HomeworkCommon.where(:homework_type => 2).each do |homework|
unless homework.homework_detail_manual
homework_detail_manual = HomeworkDetailManual.new
homework_detail_manual.ta_proportion = 0.6
homework_detail_manual.comment_status = 1
homework_detail_manual.evaluation_start = homework.created_at
homework_detail_manual.evaluation_end = homework.created_at
homework_detail_manual.evaluation_num = 3
homework_detail_manual.absence_penalty = 2
homework_detail_manual.homework_common_id = homework.id
homework_detail_manual.save
end
end
end
def down
HomeworkCommon.where(:homework_type => 2).each do |homework|
if homework.homework_detail_manual
homework.homework_detail_manual.destroy
end
end
end
end