juliano.net
juliano.net

Reputation: 8177

Shoudn't rake db:migrate version=0 remove all tables created in my migrations?

I'm trying to test my migrations from the version=0 to the last version, however when I run rake db:migrate version=0 it doesn't remove any table.

Why?

Upvotes: 0

Views: 384

Answers (2)

Purry
Purry

Reputation: 241

You could try $ bundle exec rake db:rollback to unload the previous table.

Upvotes: 0

joshua.paling
joshua.paling

Reputation: 13952

Don't test your migrations all the way through. Migrations are just for applying changes to the database, not for building it from scratch - that's what schema.rb is for.

To rebuild your database from scratch, use rake db:schema:load, which will build your database from schema.rb.

In fact, regarding migrations, some people will even delete migrations that are old and have run everywhere that they'll need to run. Really, there's no need to keep them around.

The more migrations you have to run at one time, the more likely you are to have issues. Don't even bother trying it, it's a futile exercise. You never need to do it.

Upvotes: 3

Related Questions