部分评分数据重复

This commit is contained in:
sw 2015-06-30 14:30:11 +08:00
parent 88130a4d92
commit 156f2f9a2e
2 changed files with 14 additions and 11 deletions

View File

@ -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

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20150619060110) do
ActiveRecord::Schema.define(:version => 20150630031857) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -721,16 +721,6 @@ ActiveRecord::Schema.define(:version => 20150619060110) do
add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id"
create_table "journal_details_copy", :force => true do |t|
t.integer "journal_id", :default => 0, :null => false
t.string "property", :limit => 30, :default => "", :null => false
t.string "prop_key", :limit => 30, :default => "", :null => false
t.text "old_value"
t.text "value"
end
add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id"
create_table "journal_replies", :id => false, :force => true do |t|
t.integer "journal_id"
t.integer "user_id"