How can I migrate my database with rails to the first revision without dropping the database first?

It works even if you're using the newer timestamped migration files.

Rake db:migrate VERSION=0 It works even if you're using the newer timestamped migration files.

Thank you; this is what I was looking for. I had tried rake:db:migrate:down VERSION=0, but down looks for particular versions, whereas db:migrate doesn't. – Rudd Zwolinski Jul 29 '09 at 14:20 Does not work with rails 3.1.0 rc 4: No migration with version number 0 – Marc-André Lafortune Jun 13 at 21:50.

In addition to jdl's (correct) solution above, another hack-y way to acheive this is to do rake db:rollback STEP=1000000, where 1000000 is a large number, larger than the number of migrations you'll ever have. It will rollback as far as it can up to 1000000 times, or however many times you put as the STEP.

It's moderately hackish, but you could do a query to find the first VERSION in schema_migrations and then call rake db:migrate:down to get that VERSION (I'm assuming you want to package up a "reset" script for your app). That will, of course, require that the down methods on all your migrations work properly.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions