Forum: Ruby on Rails running rake commands from rake migrate

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jason E. (Guest)
on 2006-01-23 19:05
(Received via mailing list)
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
James A. (Guest)
on 2006-01-23 19:11
(Received via mailing list)
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
Jason E. (Guest)
on 2006-01-23 21:01
(Received via mailing list)
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
Jason E. (Guest)
on 2006-01-23 23:18
(Received via mailing list)
I found the answer to my own question and decided to post it.

The answer is here:
http://thinkingincode.blogspot.com/2005/12/adding-...

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 topic is locked and can not be replied to.