Rails 6 adds rails db:prepare to create and migrate and seed the database

Prateek vyas
1 min readJul 11, 2021

--

Rails 6 adds a new task rails db:prepare!

Let’s suppose you cloned a project and that consists of some seed data and BIG schema .

What you would be doing after cloning the project is that you’ll surely be using the following command to complete your database setup right?

  1. ) rails db:create #to create the database
  2. ) rails db:migrate #to migrate the tables from schema to database
  3. ) rails db:seed #to seed the data

Well now you don’t need to run these tasks individually if you’ve switched to rails 6

you just need to run rails db:prepare

This could save you some time.

here’s the commit message from the contributers

I have implemented rake db:prepare which creates the database, loads the schema, run the migrations and initializes with the seed data
(use db:reset to also drop the database first). This rake task runs in an idempotent way

Please have a look at the Pull request

Thanks for giving this blog a read

Happy coding!

--

--

Prateek vyas
Prateek vyas

Written by Prateek vyas

Hello i am prateek vyas working as a ruby developer

No responses yet