管理员界面专业添加新的迁移

This commit is contained in:
huang 2017-08-27 10:34:59 +08:00
parent d83a27075e
commit 70b28f07bb
1 changed files with 12 additions and 0 deletions

View File

@ -0,0 +1,12 @@
class ManagementsZhuanye < ActiveRecord::Migration
def up
sql = "SELECT distinct(major_id) FROM `major_courses`"
MajorCourse.where("0=0").update_all(:support_shixuns, 0)
MajorCourse.find_by_sql(sql).each do |mc|
Major.where(:id => mc.try(:major_id)).first.update_column(:support_shixuns, 1)
end
end
def down
end
end