From 6a8a82e85af36fec491d847a1e4382e333f32001 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 5 Apr 2016 11:23:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=91=A8=E6=B5=B7=E8=8A=B3?= =?UTF-8?q?=E8=80=81=E5=B8=882882=E4=BD=9C=E4=B8=9A=E7=9A=84=E5=AD=A6?= =?UTF-8?q?=E7=94=9F=E5=8C=BF=E8=AF=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20160405021915_delete_anonymous_work.rb | 19 +++++++++++++++++++ db/schema.rb | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20160405021915_delete_anonymous_work.rb diff --git a/db/migrate/20160405021915_delete_anonymous_work.rb b/db/migrate/20160405021915_delete_anonymous_work.rb new file mode 100644 index 000000000..1677b248a --- /dev/null +++ b/db/migrate/20160405021915_delete_anonymous_work.rb @@ -0,0 +1,19 @@ +class DeleteAnonymousWork < ActiveRecord::Migration + def up + student_works = StudentWork.where("homework_common_id = 2882").map{|work| work.id} unless StudentWork.where("homework_common_id = 2882").empty? + student_work_ids = "(" + student_works.join(",") + ")" + student_work_scores = StudentWorksScore.where("student_work_id in #{student_work_ids}") + unless student_work_scores.empty? + student_work_scores.each do |sscore| + student_work = StudentWork.find sscore.student_work_id + student_work.student_score = 0 unless student_work.nil? + student_work.absence_penalty = 0 + sscore.destroy + student_work.save + end + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 8041b347b..d6c454cb0 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 => 20160328022623) do +ActiveRecord::Schema.define(:version => 20160405021915) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -1289,6 +1289,7 @@ ActiveRecord::Schema.define(:version => 20160328022623) do t.datetime "updated_at", :null => false t.string "field_type" t.integer "hide", :default => 0 + t.integer "status", :default => 1 end create_table "organizations", :force => true do |t|