Reputation: 4572
I'm working on a personal project and I have a strange doubt. At the localhost, I do rake db:reset
almost every time and I always need to run another task named newsworker:create (in other words, I run rake newsworker:create
).
rake db:reset
?rake db:create
and other tasks?Thanks!
Upvotes: 2
Views: 562
Reputation: 54882
In my opinion, the best way is to create your own rake task calling all the tasks needed (to avoid changing Rails/Rake basic tasks):
# lib/tasks/reset_and_create
namespace :database do
desc 'Reset the database to a fresh and clean DB ready for use'
task :reset_and_create do
Rake::Task['db:reset'].invoke
Rake::Task['newsworker:create'].invoke
# if you need to pass arguments to your tasks, use:
# Rake::Task['your_task'].invoke(your_arg, another_arg)
end
end
And use it like this:
rake database:reset_and_create
Upvotes: 5