Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
commit
3c89de4c81
@ -0,0 +1,5 @@
|
|||||||
|
class AddProjectIdToHomeworkAttach < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :homework_attaches, :project_id, :integer, default: 0
|
||||||
|
end
|
||||||
|
end
|
@ -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
|
Loading…
Reference in new issue