From 156f2f9a2e4dc57896db4e7bc40d420554fde94c Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 30 Jun 2015 14:30:11 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E5=88=86=E8=AF=84=E5=88=86=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=87=8D=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20150630031857_delete_same_score.rb | 13 +++++++++++++ db/schema.rb | 12 +----------- 2 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 db/migrate/20150630031857_delete_same_score.rb diff --git a/db/migrate/20150630031857_delete_same_score.rb b/db/migrate/20150630031857_delete_same_score.rb new file mode 100644 index 000000000..261a54552 --- /dev/null +++ b/db/migrate/20150630031857_delete_same_score.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index c57f435be..c0d1ce7fc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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"