Newbie -- Migration Error

I just performed a couple of migrations - one adding database columns:

def self.up    add_column :properties_sfar_commercial, :auctions_desc, :string     add_column :properties_sfar_commercial, :bank_owned_desc, :string     add_column :properties_sfar_commercial, :short_sales_desc, :string     add_column :properties_sfar_commercial, :trades_desc, :string      add_column :properties_sfar_commercial, :listing_price, :string     add_column :properties_sfar_commercial, :selling_price, :string     add_column :properties_sfar_commercial, :selling_date, :string     add_column :properties_sfar_commercial, :selling_agent_id, :string      add_column :properties_sfar_commercial, :selling_agent_name, :string     add_column :properties_sfar_commercial, :selling_co_agent_id, :string     add_column :properties_sfar_commercial, :selling_co_agent_name, :string      add_column :properties_sfar_commercial, :selling_office_id, :string     add_column :properties_sfar_commercial, :selling_office_name, :string     add_column :properties_sfar_commercial, :selling_co_office_id, :string     add_column :properties_sfar_commercial, :selling_co_office_name, :string   end

one removing:

  def self.up   remove_column :properties_sfar_commercial, :area_display   remove_column :properties_sfar_commercial, :search_price   remove_column :properties_sfar_commercial, :co_office_phone   remove_column :properties_sfar_commercial, :garage_spaces   remove_column :properties_sfar_commercial, :virtual_tour_url   remove_column :properties_sfar_commercial, :contact_phone_1   remove_column :properties_sfar_commercial, :co_agent_phone_1   remove_column :properties_sfar_commercial, :price_change   end

And now that all columns are as they should be (I think?) I get this error on rake:

** Invoke idx:load_properties (first_time) ** Execute idx:load_properties ** Execute idx:update_db rake aborted! no implicit conversion from nil to integer /var/www/apps/quickidx/releases/20080519171438/lib/idx/sfar_commercial.rb:16:in `' /var/www/apps/quickidx/releases/20080519171438/lib/idx/sfar_commercial.rb:16:in `map_property' /var/www/apps/quickidx/releases/20080519171438/lib/tasks/idx.rake:84 /var/www/apps/quickidx/releases/20080519171438/lib/quickidx.rb:142:in `parse' /var/www/apps/quickidx/releases/20080519171438/lib/quickidx.rb:136:in `parse' /var/www/apps/quickidx/releases/20080519171438/lib/tasks/idx.rake:52 /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:544:in `execute' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in `invoke_with_call_chain' /usr/lib/ruby/1.8/thread.rb:135:in `synchronize' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `invoke_with_call_chain' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:518:in `invoke_prerequisites' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1183:in `each' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:515:in `invoke_prerequisites' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:507:in `invoke_with_call_chain' /usr/lib/ruby/1.8/thread.rb:135:in `synchronize' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `invoke_with_call_chain' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1931:in `invoke_task' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:in `top_level' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:in `run' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:in `run' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/bin/rake:31 /usr/bin/rake:16

I'm new at Ruby on Rails but know that we are running 2.0.2 and this would be the first time we have ever seen this error.

Anyone able to diagnose? Thanks much

** Invoke idx:load_properties (first_time) ** Execute idx:load_properties ** Execute idx:update_db rake aborted! no implicit conversion from nil to integer /var/www/apps/quickidx/releases/20080519171438/lib/idx/sfar_commercial.rb:1 6:in `' /var/www/apps/quickidx/releases/20080519171438/lib/idx/sfar_commercial.rb:1 6:in

Have you had a look at the code here ?

Fred

Look at line 16 of sfar_commercial.rb. The error indicates that some variable (or return value) is nil when then code was expecting an integer. My guess is that it was trying to index an array with nil (hence the reference to '').

In my project, the developer who writes a migration that changes tables is typically the same person who changes the code to work with the changes. But, it sounds like you got these migrations from a third-party source, someone who is responsible for the data but not the code written to use it?

Anyway, I would recommend checking to see how "property[:area]" gets used before commenting out the line. There could be other changes needed. You should also check on how the program uses the other columns that were removed. (The column names should most likely appear somewhere in the code). You might also want to think about whether your program needs to do something with the new columns. This will all probably involve a lot of digging through the code, reading it, and understanding what it is doing and why.

All the migration does is to change the structure of the database. That file (sfar_commercial.rb) is part of the application written by the original builder. Someone will have to work out what the code was doing and work out what it should now do instead.

Good luck

Colin