Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combining many rake tasks into one rake task

Tags:

Instead of running each rake task individually like this:

rake db:drop rake db:create rake db:migrate rake db:load 

I want to run one rake task that does all for.

This is what I have for my rakefile:

desc 'This rebuilds development db' namespace :rebuild_dev do  Rake::Task["db:drop"].execute  Rake::Task["db:create"].execute  Rake::Task["db:migrate"].execute  Rake::Task["db:load"].execute end 

The above doesn't work when I run it.

like image 200
Amir Avatar asked Dec 11 '09 20:12

Amir


People also ask

How do I list all rake tasks?

You can get a list of Rake tasks available to you, which will often depend on your current directory, by typing rake --tasks .

How do I run a specific rake task?

Go to Websites & Domains and click Ruby. After gems installation you can try to run a Rake task by clicking Run rake task. In the opened dialog, you can provide some parameters and click OK - this will be equivalent to running the rake utility with the specified parameters in the command line.

What is a Ruby rake task?

Rake is a popular task runner for Ruby and Rails applications. For example, Rails provides the predefined Rake tasks for creating databases, running migrations, and performing tests. You can also create custom tasks to automate specific actions - run code analysis tools, backup databases, and so on.

How do rake tasks work?

These are small tasks that without Rake would be scattered all over your project on different files. Rake centralizes access to your tasks. Rake also makes a few things easier, like finding files that match a certain pattern & that have been modified recently.


1 Answers

You can do it with dependencies on a task with no body.

desc 'This rebuilds development db' task :rebuild_dev => ["db:drop", "db:create", "db:migrate", "db:load"] 
like image 158
madlep Avatar answered Dec 04 '22 23:12

madlep