class ClearCourseStatus < ActiveRecord::Migration
  def up
    # 删除重复的课程状态
    # 之前做迁移的时候未加验证可能引起此问题
    courseidlist = "(-1"
    CourseStatus.all.each do |status|
      sql = "delete from course_statuses where course_id=" + status.course_id.to_s  + " and id<>" + status.id.to_s +
      " and course_id not in " +courseidlist + ")"
      courseidlist += "," +  status.course_id.to_s;
      execute(sql)
    end
  end

  def down
  end
end
