Running rake commands from rake migrate

Hi there,

How can I run rake commands from a rake migration? I’m looking to run
rake engine_migrate and others commands from a migration in order to
migrate my engines along with my core app. Any advice is appreciated.

Thanks,
Jason

You could just include the task in the dependencies for your new task,
i.e.

—RAILS_ROOT/lib/tasks/app.rake—

desc ‘Migrate entire application’
task :app_migrate => [:migrate, :engine_migrate]

… I think it might actually be that simple.

  • james

hi,

Thanks for the info. It’s not quite what I need though.

I’m switching from login_generator to login_engine and I need to be able
to drop the incompatible user table, then run rake engine_migrate and
rake bootstrap and others to set up user_engine and login_engine.

Thanks,
Jason

I found the answer to my own question and decided to post it.

The answer is here:
http://thinkingincode.blogspot.com/2005/12/adding-options-to-rake-tasks.html

Rake::Task[:engine_migrate].invoke

will run a rake task from within a migration and other ruby code. rake
takes it’s options from ENV[].

to run “rake engine_migrate ENGINE=user” do

ENV[“ENGINE”]=“user”
Rake::Task[:engine_migrate].invoke

FYI,
Jason

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs