From 8f78177d47c198eec194a9ca6a68910089ad62e4 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 18 Jun 2014 11:51:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE=E8=BF=81?= =?UTF-8?q?=E7=A7=BB=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...18020535_remove_data_to_homework_attach.rb | 25 +++++++++++++++++++ db/schema.rb | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20140618020535_remove_data_to_homework_attach.rb diff --git a/db/migrate/20140618020535_remove_data_to_homework_attach.rb b/db/migrate/20140618020535_remove_data_to_homework_attach.rb new file mode 100644 index 000000000..16a1b4911 --- /dev/null +++ b/db/migrate/20140618020535_remove_data_to_homework_attach.rb @@ -0,0 +1,25 @@ +class RemoveDataToHomeworkAttach < ActiveRecord::Migration + def up + bidding_projects = BidingProject.joins(:bid).where("bids.reward_type = 3") + bidding_projects.each do |biding| + homework = HomeworkAttach.new + homework.project_id = biding.project_id + homework.bid_id = biding.bid_id + homework.created_at = biding.created_at + homework.updated_at = biding.updated_at + homework.reward = biding.reward + homework.description = biding.description + homework.user_id = biding.user_id + homework.state = 0 + homework.save + end + end + + def down + bidding_projects = BidingProject.joins(:bid).where("bids.reward_type = 3") + bidding_projects.each do |biding| + homework = HomeworkAttach.where("bid_id = #{biding.bid_id} and user_id = #{biding.user_id}") + homework.first.destroy + end + end +end diff --git a/db/schema.rb b/db/schema.rb index fc2151165..18cc2a718 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 => 20140617092219) do +ActiveRecord::Schema.define(:version => 20140618020535) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false