# Rake migrate the first time - uses more than schema\_info?

**URL:** <https://www.ruby-forum.com/t/rake-migrate-the-first-time-uses-more-than-schema-info/101963>\
**Category:** Rails\
**Created:** [August 8, 2006, 10:44pm UTC](https://www.ruby-forum.com/t/rake-migrate-the-first-time-uses-more-than-schema-info/101963 "2006-08-08T22:44:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [August 8, 2006, 10:44pm UTC](https://www.ruby-forum.com/t/rake-migrate-the-first-time-uses-more-than-schema-info/101963/1 "2006-08-08T22:44:55Z")

</div>

All,

I have two migration files, file 1 and file 2.

For reasons that I don’t want to go into unless I must, I want to only  
run file 2 on my production database (file 1 contains a bunch of table  
creation stuff for already existing tables).

I figured if I created a schema\_info table and set the version in it to  
1, then I could just run rake db:migrate RAILS\_ENV=production and just  
file 2 would get run.

However, it keeps trying to run file1 and fails because as I said, those  
things already exist. Basically, it is ignoring or not seeing the  
schema\_info version. I am pretty sure that it should be able to read  
the version from that table.

So, I am led to believe that the first time that you run rake  
db:migrate, it must be looking for something in addition to/instead of  
the version in the schema\_info table to figure out that it wants to run  
starting with the first migration file.

Here’s the output of rake --trace db:migrate

[dusan@exmit2 current]$ rake --trace db:migrate RAILS\_ENV=production  
(in /home/dusan/eSimplyTest/releases/20060808203414)  
\*\* Invoke db:migrate (first\_time)  
\*\* Invoke environment (first\_time)  
\*\* Execute environment  
\*\* Execute db:migrate

Do I have to fiddle with my migration files on my production box?

Any info. on this?

Thanks,  
Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [August 8, 2006, 10:47pm UTC](https://www.ruby-forum.com/t/rake-migrate-the-first-time-uses-more-than-schema-info/101963/2 "2006-08-08T22:47:40Z")

</div>

I’ve verified that it is looking only at schema\_info.

There must be something wrong with my production DB setup so that  
schema\_info can’t be seen.

When rake runs for a given environment, won’t it connect to the database  
as the user specified in database.yml for the environment name specified  
in RAILS\_ENV?

Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [August 8, 2006, 11:17pm UTC](https://www.ruby-forum.com/t/rake-migrate-the-first-time-uses-more-than-schema-info/101963/3 "2006-08-08T23:17:45Z")

</div>

My problem is that my production DB user is not connecting correctly and  
is not able to read the schema\_info table.

Wes

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [August 9, 2006, 6:29pm UTC](https://www.ruby-forum.com/t/rake-migrate-the-first-time-uses-more-than-schema-info/101963/4 "2006-08-09T18:29:05Z")

</div>

On Tue, 2006-08-08 at 23:17 +0200, Wes G. wrote:

> My problem is that my production DB user is not connecting correctly and  
> is not able to read the schema\_info table.

* * *

one of us can fix that and it isn’t me

Craig

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [August 9, 2006, 6:38pm UTC](https://www.ruby-forum.com/t/rake-migrate-the-first-time-uses-more-than-schema-info/101963/5 "2006-08-09T18:38:37Z")

</div>

It’s fixed. Thanks for responding.

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [August 9, 2006, 6:58am UTC](https://www.ruby-forum.com/t/rake-migrate-the-first-time-uses-more-than-schema-info/101963/6 "2006-08-09T06:58:14Z")

</div>

On Tue, 2006-08-08 at 22:44 +0200, Wes G. wrote:

> file 2 would get run.
> 
> Any info. on this?

* * *

how about something like…

rake db:schema:dump  
put the result into schema.rb  
set version value in schema\_info table to ‘1’

and then do rake db:migrate RAILS\_ENV=production --trace

Craig

---

<div class="post-metadata">

**Author:** ![weyus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7ab992/32.png) [@weyus](https://www.ruby-forum.com/u/weyus)\
**Post date:** [August 15, 2006, 2:19pm UTC](https://www.ruby-forum.com/t/rake-migrate-the-first-time-uses-more-than-schema-info/101963/7 "2006-08-15T14:19:35Z")

</div>

On Tue, 2006-08-08 at 22:47 +0200, Wes G. wrote:

> I’ve verified that it is looking only at schema\_info.
> 
> There must be something wrong with my production DB setup so that  
> schema\_info can’t be seen.
> 
> When rake runs for a given environment, won’t it connect to the database  
> as the user specified in database.yml for the environment name specified  
> in RAILS\_ENV?

* * *

try connecting to the database as that user from the command line client

Craig
