迁移空数据问题

This commit is contained in:
huang 2016-04-24 11:25:29 +08:00
parent 081aea8b02
commit 5d506458df
1 changed files with 14 additions and 10 deletions

View File

@ -1,5 +1,6 @@
class DeleteAnonymousWork < ActiveRecord::Migration
def up
begin
student_works = StudentWork.where("homework_common_id = 2882").map{|work| work.id} unless StudentWork.where("homework_common_id = 2882").empty?
student_work_ids = "(" + student_works.join(",") + ")"
student_work_scores = StudentWorksScore.where("student_work_id in #{student_work_ids}")
@ -12,6 +13,9 @@ class DeleteAnonymousWork < ActiveRecord::Migration
student_work.save
end
end
rescue => e
logger.error "[Errno::ENOENT] ===> #{e}"
end
end
def down