socialforge/db/migrate/20140604011630_add_courseid...

16 lines
399 B
Ruby

class AddCourseidToToMembers < ActiveRecord::Migration
def change
add_column :members, :course_id, :int
# 课程成员数据迁移
Member.all.each do |member|
project = Project.find_by_id(member.project_id)
if project && project.project_type == 1
member.course_id = member.project_id
member.project_id = nil
member.save
end
end
end
end