On Tue, Apr 6, 2010 at 11:29 PM, Ryan Waldron <[email protected]> wrote: > You'll also need to remove that migration's entry from the > 'schema_migrations' table. That's how Rails keeps up with what > migrations exist, and whether it's done them all.
Running rake db:migrate:down VERSION=XXX should remove the entry. Otherwise rake db:migrate wouldn't run the migration again. A normal use case for migrate down is: rake db:migrate #oops something was wrong in migration 123456 rake db:migrate:down VERSION=123456 edit db/migrate/123456_whatever_it_does rake db:migrate > On Tue, Apr 6, 2010 at 10:10 PM, GoodGets <[email protected]> wrote: >> What exactly does rake db:migrate:down VERSION=XXX do? I understand >> that it runs the "down" migration, completely removing any columns/ >> tables that migration may have created, Well it does whatever YOU told it to in the down part of the migration. It's up to you (or whatever you use to edit/generate the migration) to write the correct code there. I tend to use Textmate snippets from the rails bundle to do migrations, and the table/column migration snippets will generate 'undo' code in the down migration when you expand them in the up migration. But YMMV depending on what tools you use. >> but does this mean that I can >> can delete these migration files as well? I'd like for Rails to have >> no knowledge of their existence. (I was allowing user profile pics >> with Paperclip, but have since decided to just use their Gravatars.) >> I know you can delete a migration, and even delete those columns from >> the schema, but Rails still "remembers" these changes and just updates >> them the next time you rake db:migrate. So, I'd like to completely >> rid my app of a particular migration, is rake db:migrate:down then >> deleting that migration from the migrate folder the way to do it? When you do rake db:migration the rake task looks for migrations under db/migrate which don't have entries in the schema_migrations table, and runs those (actually I think it's a bit more subtle than that, there's been discussion of a 'bug' which can make the task ignore migrations with a timestamp older than the newest one in schema_migrations, which can keep migrations merged from another branch NOT to be run. But... If you run rake db:migrate:down version=XXX and then remove the file db/migrate/XXX_whatever from your source, the rake task won't see it and it will be gone. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

