socialforge/db/migrate/20140603081801_add_courseid...

18 lines
672 B
Ruby

class AddCourseidToEnabledModules < ActiveRecord::Migration
def change
add_column :enabled_modules, :course_id, :int
EnabledModule.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all("course_id = project_id")
EnabledModule.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all(project_id: -1)
#EnabledModule.all.each do |enablemodule|
# project = Project.find_by_id(enablemodule.project_id)
# if project && project.project_type == 1
# enablemodule.course_id = enablemodule.project_id
# enablemodule.project_id = -1
# enablemodule.save
# end
#end
end
end