u4iwxq
Last Updated: February 25, 2016
·
681
· muszynskis

Rails: Recreating the Database One-Liner

Handy One-Liner

To recreate the database, type in your terminal:

rake db:drop && rake db:create && rake db:migrate && rake db:seed 

Create an alias

You can create an alias for recreating the database:

alias recreate="rake db:drop && rake db:create && rake db:migrate && rake db:seed"

And now for recreating the database, just type: recreate.

Make your alias permanent

1) Open your ~/.bashrc file.

vi ~/.bashrc

2) Put your alias inside.

alias recreate="rake db:drop && rake db:create && rake db:migrate && rake db:seed"

3) Restart terminal.