Commit 6741d167e1b91ab1ec8d7700673e98dd6f0ef2d2
1 parent
ec0761a4
Exists in
staging
and in
42 other branches
ActionItem380: fixed the migrations that do not function without the removed code
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1803 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
1 changed file
with
8 additions
and
6 deletions
Show diff stats
db/migrate/033_destroy_organization_and_person_infos.rb
1 | class DestroyOrganizationAndPersonInfos < ActiveRecord::Migration | 1 | class DestroyOrganizationAndPersonInfos < ActiveRecord::Migration |
2 | def self.up | 2 | def self.up |
3 | Person.find(:all).each do |i| | 3 | Person.find(:all).each do |i| |
4 | - i.name = i.info.name unless i.info.name.nil? | ||
5 | - i.address = i.info.address unless i.info.address.nil? | ||
6 | - for field in [ :photo, :contact_information, :birth_date, :sex, :city, :state, :country ] do | ||
7 | - i.send("#{field}=", i.info.send(field)) | 4 | + info = ActiveRecord::Base.connection.select_one("select * from person_infos where person_id = #{i.id}") |
5 | + i.name = info["name"] unless info["name"].nil? | ||
6 | + i.address = info["address"] unless info["address"].nil? | ||
7 | + [ "photo", "contact_information", "birth_date", "sex", "city", "state", "country" ].each do |field| | ||
8 | + i.send("#{field}=", info[field]) | ||
8 | end | 9 | end |
9 | i.save! | 10 | i.save! |
10 | end | 11 | end |
11 | drop_table :person_infos | 12 | drop_table :person_infos |
12 | 13 | ||
13 | Organization.find(:all).each do |i| | 14 | Organization.find(:all).each do |i| |
14 | - for field in [ :contact_person, :contact_email, :acronym, :foundation_year, :legal_form, :economic_activity, :management_information, :validated ] do | ||
15 | - i.send("#{field}=", i.info.send(field)) | 15 | + info = ActiveRecord::Base.connection.select_one("select * from organization_infos where organization_id = #{i.id}") |
16 | + [ "contact_person", "contact_email", "acronym", "foundation_year", "legal_form", "economic_activity", "management_information", "validated" ].each do |field| | ||
17 | + i.send("#{field}=", info[field]) | ||
16 | end | 18 | end |
17 | i.save! | 19 | i.save! |
18 | end | 20 | end |