# Newbie -- Migration Error

**URL:** <https://www.ruby-forum.com/t/newbie-migration-error/170137>\
**Category:** Rails\
**Created:** [June 12, 2009, 7:30pm UTC](https://www.ruby-forum.com/t/newbie-migration-error/170137 "2009-06-12T19:30:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![carolinecblaker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6a8cbe/32.png) [@carolinecblaker](https://www.ruby-forum.com/u/carolinecblaker)\
**Post date:** [June 12, 2009, 7:30pm UTC](https://www.ruby-forum.com/t/newbie-migration-error/170137/1 "2009-06-12T19:30:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![carolinecblaker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6a8cbe/32.png) [@carolinecblaker](https://www.ruby-forum.com/u/carolinecblaker)\
**Post date:** [June 12, 2009, 7:50pm UTC](https://www.ruby-forum.com/t/newbie-migration-error/170137/2 "2009-06-12T19:50:52Z")

</div>

On Jun 12, 6:30 pm, Caroline B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> \*\* 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

---

<div class="post-metadata">

**Author:** ![carolinecblaker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6a8cbe/32.png) [@carolinecblaker](https://www.ruby-forum.com/u/carolinecblaker)\
**Post date:** [June 12, 2009, 7:54pm UTC](https://www.ruby-forum.com/t/newbie-migration-error/170137/3 "2009-06-12T19:54:48Z")

</div>

Frederick C. wrote:

> On Jun 12, 6:30ï¿½pm, Caroline B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > \*\* 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

Yes, but as a newbie, errors cause and solutions don’t just, you know,  
jump off the page.  
Plus, I didn’t build this system but am assigned to maintain it, so  
every new thing is just that. A new thing. To me it looks like “1 space  
6” in array. But what does that mean and how do I fix it? I’m not trying  
to look stupid. I’m just trying to get my work done.

thanks for taking the time to help…

---

<div class="post-metadata">

**Author:** ![carolinecblaker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6a8cbe/32.png) [@carolinecblaker](https://www.ruby-forum.com/u/carolinecblaker)\
**Post date:** [June 12, 2009, 8:01pm UTC](https://www.ruby-forum.com/t/newbie-migration-error/170137/4 "2009-06-12T20:01:32Z")

</div>

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 ‘[]’).

On Jun 12, 1:54 pm, Caroline B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![carolinecblaker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6a8cbe/32.png) [@carolinecblaker](https://www.ruby-forum.com/u/carolinecblaker)\
**Post date:** [June 12, 2009, 8:09pm UTC](https://www.ruby-forum.com/t/newbie-migration-error/170137/5 "2009-06-12T20:09:51Z")

</div>

Paul L. wrote:

> 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 ‘[]’).
> 
> On Jun 12, 1:54ï¿½pm, Caroline B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Ok - this line is as follows

```
property[:area] = data[map['area_display']]

```

Not surprisingly this would refer to one of the columns that I just  
migrated out! Apparently the feed author has discontinued it and now  
that my databases are updated I’m getting this error. But I \*did migrate  
it out. I suppose this file does not follow awareness of migrations.

In any case, is it OK just to comment out this line? I know that Ruby is  
a sensitive system to a lot of scrap hap hazard cutting around the code.  
But hey! that’s what its there for right?

Thanks for all your help.

---

<div class="post-metadata">

**Author:** ![carolinecblaker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6a8cbe/32.png) [@carolinecblaker](https://www.ruby-forum.com/u/carolinecblaker)\
**Post date:** [June 12, 2009, 9:02pm UTC](https://www.ruby-forum.com/t/newbie-migration-error/170137/6 "2009-06-12T21:02:35Z")

</div>

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.

On Jun 12, 2:09 pm, Caroline B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![carolinecblaker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6a8cbe/32.png) [@carolinecblaker](https://www.ruby-forum.com/u/carolinecblaker)\
**Post date:** [June 12, 2009, 10:46pm UTC](https://www.ruby-forum.com/t/newbie-migration-error/170137/7 "2009-06-12T22:46:28Z")

</div>

2009/6/12 Caroline B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Â Â property[:area] = data[map[‘area\_display’]]
> 
> Not surprisingly this would refer to one of the columns that I just  
> migrated out! Apparently the feed author has discontinued it and now  
> that my databases are updated I’m getting this error. But I \*did migrate  
> it out. I suppose this file does not Â follow awareness of migrations.

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
