# Why does config.gem mess up migration?

**URL:** <https://www.ruby-forum.com/t/why-does-config-gem-mess-up-migration/183387>\
**Category:** Rails\
**Created:** [February 12, 2010, 8:43pm UTC](https://www.ruby-forum.com/t/why-does-config-gem-mess-up-migration/183387 "2010-02-12T20:43:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rickm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/90ced4/32.png) [@rickm](https://www.ruby-forum.com/u/rickm)\
**Post date:** [February 12, 2010, 8:43pm UTC](https://www.ruby-forum.com/t/why-does-config-gem-mess-up-migration/183387/1 "2010-02-12T20:43:37Z")

</div>

I was working this morning, trying to clean up my project and I did  
something that sent migrations to hell-in-a-hand-basket.

I tried to run rake db:migrate --trace I got the following error msg:  
(in /Users/richardmartin/NetBeansProjects/ReTrace)  
\*\* Invoke db:migrate (first\_time)  
\*\* Invoke environment (first\_time)  
\*\* Execute environment  
rake aborted!  
Mysql::Error: Table ‘rt\_dev.priorities’ doesn’t exist: SELECT \* FROM  
`priorities` LIMIT 1  
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active\_record/  
connection\_adapters/abstract\_adapter.rb:219:in `log' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/ connection_adapters/mysql_adapter.rb:323:in `execute’  
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active\_record/  
connection\_adapters/mysql\_adapter.rb:608:in `select' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/ connection_adapters/abstract/database_statements.rb:7:in `select\_all\_without\_query\_cache’

I looked at the environment.rb and noticed one thing that was  
“abnormal” from my experience. I had cut-pasted the following  
config.gem line:  
config.gem ‘thoughtbot-factory\_girl’, :lib =\>  
‘factory\_girl’, :source =\> ‘[http://gems.github.com](http://gems.github.com)’

So I changed it to  
config.gem ‘thoughtbot-factory\_girl’, :lib =\>false, :source =\>  
‘[http://gems.github.com](http://gems.github.com)’

to look like the other config.gem lines and everything went back to  
normal. I have since moved all of them to the config/environments/  
test.rb and cucumber.rb since that was where I needed them.

My question that I hope some guru will answer for my own education:  
Why did thaving the clause " :lib =\> ‘factory\_girl’ " cause problems  
with migrations?

Just want to attain a higher level of understanding.

Rick

---

<div class="post-metadata">

**Author:** ![rickm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/90ced4/32.png) [@rickm](https://www.ruby-forum.com/u/rickm)\
**Post date:** [February 13, 2010, 5:05pm UTC](https://www.ruby-forum.com/t/why-does-config-gem-mess-up-migration/183387/2 "2010-02-13T17:05:34Z")

</div>

On Feb 12, 2:42 pm, bearblu [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> `priorities` LIMIT 1  
> /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active\_record/  
> connection\_adapters/abstract\_adapter.rb:219:in `log' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/ connection_adapters/mysql_adapter.rb:323:in `execute’  
> /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active\_record/  
> connection\_adapters/mysql\_adapter.rb:608:in `select' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/ connection_adapters/abstract/database_statements.rb:7:in `select\_all\_without\_query\_cache’

[snip]

> My question that I hope some guru will answer for my own education:  
> Why did thaving the clause " :lib =\> ‘factory\_girl’ " cause problems  
> with migrations?
> 
> Just want to attain a higher level of understanding.

You’ll get a lot more understanding if you don’t cut the stack trace  
off before it gets interesting… 🙂

Anyway, the relevant bit appears to be missing from the trace above -  
but I’d hazard that you’re somehow querying the DB in your factory  
definitions, most likely a line like “Priority.first” or similar.

–Matt J.
