re: Dropping the working database (NO! NO! NO!) VIEW POST

TOP OF THREAD FULL DISCUSSION
re: It's a rite of passage. Welcome! And next time use a migration framework (I like sqitch)so you can reconstitute databases when and where you want t...
 

Rails already has its own migration framework, which devise uses to set up the database changes needed for it to work.

I guess what Saral did wrong is not that he forgot to use migrations, but rather, to make a backup of the database.

If you are using PostgreSQL (which I recommend, it is way better than MySQL), you can use this command to create a copy of your DB:

createdb -T development_db development_db_copy

And when you want to restore your working copy to the backup, this one liner will drop the current one, create it from your backup and run rails db:migrate to bring everything up to date:

dropdb development_db && createdb -T development_db_copy development_db && bin/rails db:migrate
 

Yeap. I think this definitely does address my issue and how I could have worked around it. Will give it a go next time I am working with my database.

Thank you Patricio. :D

code of conduct - report abuse