部分评分数据重复
This commit is contained in:
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
|
12
db/schema.rb
12
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# 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|
|
create_table "activities", :force => true do |t|
|
||||||
t.integer "act_id", :null => false
|
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"
|
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|
|
create_table "journal_replies", :id => false, :force => true do |t|
|
||||||
t.integer "journal_id"
|
t.integer "journal_id"
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
|
|
Loading…
Reference in New Issue