# Rake db:migrate:down?

**URL:** <https://www.ruby-forum.com/t/rake-dbdown/149884>\
**Category:** Rails\
**Created:** [September 30, 2008, 8:41pm UTC](https://www.ruby-forum.com/t/rake-dbdown/149884 "2008-09-30T20:41:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![helix\_tp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ed655f/32.png) [@helix\_tp](https://www.ruby-forum.com/u/helix_tp)\
**Post date:** [September 30, 2008, 8:41pm UTC](https://www.ruby-forum.com/t/rake-dbdown/149884/1 "2008-09-30T20:41:07Z")

</div>

The behavior of rake db:migrate:down is a little bit unexpected (to me  
at least).

If I do this:  
$ rake db:version  
Current version: 20080930121212  
$ rake db:migrate:down VERSION=20080930121212

what happens is the schema in that migration is rolled back, but the  
migration version is NOT removed from schema\_migrations table. So now  
rails _thinks_ the db is at version X (according to schema\_migrations),  
when it fact its schema is _really_ at version X-1.

Am I missing something obvious here? I would have expected  
db:migrate:down to also remove that version from schema\_migrations.

Thanks

dwh

---

<div class="post-metadata">

**Author:** ![helix\_tp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ed655f/32.png) [@helix\_tp](https://www.ruby-forum.com/u/helix_tp)\
**Post date:** [October 1, 2008, 9:14pm UTC](https://www.ruby-forum.com/t/rake-dbdown/149884/2 "2008-10-01T21:14:29Z")

</div>

On Sep 30, 2:39 pm, Denis H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The behavior of rake db:migrate:down is a little bit unexpected (to me  
> at least).
> 
> If I do this:  
> $ rake db:version  
> Current version: 20080930121212  
> $ rake db:migrate:down VERSION=20080930121212
> 
> what happens is the schema in that migration is rolled back, but the  
> migration version is NOT removed from schema\_migrations table.

$ rake --describe db:migrate:down  
rake db:migrate:down  
Runs the “down” for a given migration VERSION.

> Am I missing something obvious here? I would have expected  
> db:migrate:down to also remove that version from schema\_migrations.

You probably want just “db:migrate” with a specific version:

$ rake db:migrate VERSION=20080930121212
