Faster way to write this rake command - rake db:drop db:create db:migrate db:seed

you could create a custom rake task for this - lib/tasks/db_rebuild_all.rake

namespace :db_tasks do
  desc "Rebuild database"
  task :rebuild, [] => :environment do
    raise "Not allowed to run on production" if Rails.env.production?

    Rake::Task['db:drop'].execute
    Rake::Task['db:create'].execute
    Rake::Task['db:migrate'].execute
    Rake::Task['db:seed'].execute
  end
end

then just run bundle exec rake db_tasks:rebuild


  • Run rake db:reset && rake db:seed (Note: You must have db/schema.rb file updated)
    OR
  • Run rake db:migrate:reset && rake db:seed

You could run rake db:drop and then rake db:setup.

db:setup will run rake db:create db:schema:load and db:seed

But why are you dropping and recreating your database everytime you have new migrations? That's what the migrations are there for, to make incremental changes to your existing database.