解决空数据库问题
This commit is contained in:
parent
ee2ae456ac
commit
e2c0237fcd
|
@ -6,13 +6,17 @@ class MergeTwoHomeworks < ActiveRecord::Migration
|
|||
work.update_column('homework_common_id', 3463)
|
||||
end
|
||||
end
|
||||
homework = HomeworkCommon.find 3387
|
||||
homework.destroy if homework
|
||||
stu_works = StudentWork.where("homework_common_id = 3387")
|
||||
stu_work_ids = stu_works.empty? ? "(-1)" : "(" + stu_works.map{|work| work.id}.join(',') + ")"
|
||||
stu_work_tests = StudentWorkTest.where("student_work_id in #{stu_work_ids}")
|
||||
stu_work_tests.destroy_all if stu_work_tests
|
||||
stu_works.destroy_all if stu_works
|
||||
begin
|
||||
homework = HomeworkCommon.find 3387
|
||||
homework.destroy if homework
|
||||
stu_works = StudentWork.where("homework_common_id = 3387")
|
||||
stu_work_ids = stu_works.empty? ? "(-1)" : "(" + stu_works.map{|work| work.id}.join(',') + ")"
|
||||
stu_work_tests = StudentWorkTest.where("student_work_id in #{stu_work_ids}")
|
||||
stu_work_tests.destroy_all if stu_work_tests
|
||||
stu_works.destroy_all if stu_works
|
||||
rescue Exception => e
|
||||
puts e
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
|
|
Loading…
Reference in New Issue