19 lines
609 B
Ruby
19 lines
609 B
Ruby
class DeleteUselessOrgActivities < ActiveRecord::Migration
|
|
def up
|
|
OrgActivity.all.each do |act|
|
|
if act.container_type == 'Course'
|
|
if CourseActivity.where("course_act_type=? and course_act_id =? and course_id =?", act.org_act_type, act.org_act_id, act.container_id).count == 0
|
|
act.destroy
|
|
end
|
|
else
|
|
if act.container_type == 'Project' and ForgeActivity.where("forge_act_type=? and forge_act_id =? and project_id =?", act.org_act_type, act.org_act_id, act.container_id).count == 0
|
|
act.destroy
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
def down
|
|
end
|
|
end
|