HOW TO REBUILD DATABASE WITH CAPISTRANO

I'm not sure if Capistrano comes with a built in method to do this, If you can gain access to the production machine you can just run

rake db:migrate VERSION=0 or rake db:migrate VERISON=0 RAILS_ENV=production

to redump it.

Otherwise you can always just access the database directly, drop the schema, and recreate it.

Editing a migration doesn't change the version number that the system thinks the schema is right now.

In any case, you probably need to do this manually. If the target machine is some type of POSIX (unix, etc.), you can probably do:

env RAILS_ENV=production rake db:migrate VERSION=x

To force a migration to 'x' from wherever you are now.

You can try to do this with:

cap invoke COMMAND="env RAILS_ENV=production rake db:migrate VERSION=0" ROLES=app

It might be that you want the ROLES=db, but if you have everything on a single host, that doesn't matter anyway (you could replace ROLES=db with HOST=yourhost.com if you want/need to be specific).

I think this works with both cap1.x and cap2.0, but I'm just typing, not testing, so your results may vary. (Since you want to wipe the database, I feel fairly safe suggesting that you try it.)

-Rob

Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com