# Rake migrate VERSION=0 doesn't appear to execute

**URL:** <https://www.ruby-forum.com/t/rake-migrate-version-0-doesnt-appear-to-execute/61620>\
**Category:** Rails\
**Created:** [May 25, 2006, 5:59pm UTC](https://www.ruby-forum.com/t/rake-migrate-version-0-doesnt-appear-to-execute/61620 "2006-05-25T17:59:45Z")\
**Posts on this page:** 6\
**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:** [May 25, 2006, 5:59pm UTC](https://www.ruby-forum.com/t/rake-migrate-version-0-doesnt-appear-to-execute/61620/1 "2006-05-25T17:59:45Z")

</div>

All,

I’ve decided to jump into Migrations before I get too far along on the  
DB side of things.

I already have some tables built, and I went ahead and built the  
migration that would have created them from scratch, and I made sure  
that there was a self.down section to drop them. I wanted to verify  
that I could roll back so I figured I would use rake to drop these  
pre-existing tables before I recreated them.

Sure enough, if I run rake migrate, I get the error that says the tables  
already exist. Great - that means rake can find my migration and the  
“up” section is probably valid.

However, if I do

rake migrate VERSION=0

which I am understanding should undo the first migration, nothing  
happens.

Here is the output of a trace:

C:\eclipse\workspace\eSimplyOnlineRails\>rake -t migrate VERSION=0  
(in C:/eclipse/workspace/eSimplyOnlineRails)  
\*\* Invoke migrate (first\_time)  
\*\* Invoke db:migrate (first\_time)  
\*\* Invoke environment (first\_time)  
\*\* Execute environment  
\*\* Execute db:migrate  
\*\* Invoke db:schema:dump (first\_time)  
\*\* Invoke environment  
\*\* Execute db:schema:dump  
\*\* Execute migrate

but my tables aren’t dropped.

Here’s my migration:

class CreateInitialSchema \< ActiveRecord::Migration  
def self.up  
…creates a bunch of tables  
end

def self.down  
drop\_table :target\_lists  
drop\_table :jobs  
drop\_table :stylesheets  
drop\_table :images  
drop\_table :documents  
end  
end

Does rake migrate VERSION=0 rollback the very FIRST migration?

What am I doing wrong?

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:** [May 25, 2006, 6:22pm UTC](https://www.ruby-forum.com/t/rake-migrate-version-0-doesnt-appear-to-execute/61620/2 "2006-05-25T18:22:08Z")

</div>

On 5/25/06, Wes G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> All,
> 
> Sure enough, if I run rake migrate, I get the error that says the tables  
> already exist. Great - that means rake can find my migration and the  
> “up” section is probably valid.

Your problem is probably that the tables already do exist. This makes  
Migrate error out before completing. If it were successful, it would  
set the version for the migration in the database. This probably has  
not been set (or is 0) so the Migrate Version=0 thinks it is already  
in that state.

Two options. Delete the tables, then run the initial Migration so  
it’s populated fully. Jump into the db itself and set the version  
value to 1 manually in the migrations table (sorry I should know the  
table name offhand, but don’t…it’s obvious though).

-Curtis

---

<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:** [May 25, 2006, 6:26pm UTC](https://www.ruby-forum.com/t/rake-migrate-version-0-doesnt-appear-to-execute/61620/3 "2006-05-25T18:26:56Z")

</div>

Wes G. wrote:

> Curtis S. wrote:
> 
> > On 5/25/06, Wes G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> > 
> > > All,
> > > 
> > > Sure enough, if I run rake migrate, I get the error that says the tables  
> > > already exist. Great - that means rake can find my migration and the  
> > > “up” section is probably valid.
> > 
> > Your problem is probably that the tables already do exist. This makes  
> > Migrate error out before completing. If it were successful, it would  
> > set the version for the migration in the database. This probably has  
> > not been set (or is 0) so the Migrate Version=0 thinks it is already  
> > in that state.
> > 
> > Two options. Delete the tables, then run the initial Migration so  
> > it’s populated fully. Jump into the db itself and set the version  
> > value to 1 manually in the migrations table (sorry I should know the  
> > table name offhand, but don’t…it’s obvious though).
> > 
> > -Curtis
> 
> Curtis,
> 
> That makes sense.
> 
> Thanks,  
> Wes

Yep, that was it. I modified the schema\_info table to set the current  
version to 1 and then was able to revert.

I’m happy - looks like Migrations works well so I’m glad to be able to  
integrate it into my experience and move on :).

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:** [May 25, 2006, 6:41pm UTC](https://www.ruby-forum.com/t/rake-migrate-version-0-doesnt-appear-to-execute/61620/4 "2006-05-25T18:41:59Z")

</div>

On 5/25/06, Wes G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m happy - looks like Migrations works well so I’m glad to be able to  
> integrate it into my experience and move on :).

Migrations are The Big Electron’s gift to database versioning. 🙂  
Use them, Know them, Love them…

---

<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:** [May 25, 2006, 6:25pm UTC](https://www.ruby-forum.com/t/rake-migrate-version-0-doesnt-appear-to-execute/61620/5 "2006-05-25T18:25:06Z")

</div>

Curtis S. wrote:

> On 5/25/06, Wes G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > All,
> > 
> > Sure enough, if I run rake migrate, I get the error that says the tables  
> > already exist. Great - that means rake can find my migration and the  
> > “up” section is probably valid.
> 
> Your problem is probably that the tables already do exist. This makes  
> Migrate error out before completing. If it were successful, it would  
> set the version for the migration in the database. This probably has  
> not been set (or is 0) so the Migrate Version=0 thinks it is already  
> in that state.
> 
> Two options. Delete the tables, then run the initial Migration so  
> it’s populated fully. Jump into the db itself and set the version  
> value to 1 manually in the migrations table (sorry I should know the  
> table name offhand, but don’t…it’s obvious though).
> 
> -Curtis

Curtis,

That makes sense.

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:** [May 25, 2006, 8:59pm UTC](https://www.ruby-forum.com/t/rake-migrate-version-0-doesnt-appear-to-execute/61620/6 "2006-05-25T20:59:47Z")

</div>

On Thu, 2006-05-25 at 17:59 +0200, Wes G. wrote:

> \*\* Invoke environment  
> end  
> Does rake migrate VERSION=0 rollback the very FIRST migration?
> 
> What am I doing wrong?

* * *

I can’t answer the question but I never bothered to try because the  
first schema dump I did, I copied into the first migration file and I  
was done. That was certainly capable of creating the ‘testing’ db and  
the ‘production’ db’s so I know it worked so going back to ‘0’ never  
seemed to be an issue

Craig
