From e86778a9c7e127e2cf1d7a4695ea43c779331dce Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 25 Dec 2015 10:13:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=B8=8D=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E7=9A=84=E7=95=99=E8=A8=80=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20151224090313_delete_journals_message.rb | 17 +++++++++++++++++ db/schema.rb | 3 +-- 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20151224090313_delete_journals_message.rb diff --git a/db/migrate/20151224090313_delete_journals_message.rb b/db/migrate/20151224090313_delete_journals_message.rb new file mode 100644 index 000000000..4753cc8e8 --- /dev/null +++ b/db/migrate/20151224090313_delete_journals_message.rb @@ -0,0 +1,17 @@ +class DeleteJournalsMessage < ActiveRecord::Migration + def up + count = JournalsForMessage.all.count / 30 + 2 + transaction do + for i in 1 ... count do + JournalsForMessage.page(i).per(30).each do |message| + if !message.m_parent_id.nil? and message.parent.nil? + message.destroy + end + end + end + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 52c7755e9..0758d90ed 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 => 20151218110033) do +ActiveRecord::Schema.define(:version => 20151224090313) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -1569,7 +1569,6 @@ ActiveRecord::Schema.define(:version => 20151218110033) do end add_index "student_works", ["homework_common_id", "user_id"], :name => "index_student_works_on_homework_common_id_and_user_id" - add_index "student_works", ["homework_common_id"], :name => "index" create_table "student_works_evaluation_distributions", :force => true do |t| t.integer "student_work_id"