parent
88130a4d92
commit
156f2f9a2e
@ -0,0 +1,13 @@
|
||||
class DeleteSameScore < ActiveRecord::Migration
|
||||
def up
|
||||
student_work_scores = StudentWorksScore.find_by_sql("SELECT * FROM student_works_scores AS a
|
||||
WHERE (a.student_work_id,a.user_id) IN (SELECT student_work_id,user_id FROM student_works_scores GROUP BY student_work_id,user_id HAVING COUNT(*) > 1)
|
||||
AND id NOT IN (SELECT MIN(id) FROM student_works_scores GROUP BY student_work_id,user_id HAVING COUNT(*)>1)")
|
||||
student_work_scores.each do |score|
|
||||
score.destroy
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
Loading…
Reference in new issue