Output what commands a rake task is executing
I just want to better understand how some of the built in rake tasks are operating, in particular rake db:create.
Is there a way I can view the sql commands being executed to create the database? I tried rake db:create --verbose --trace, but all I got was
** Invoke db:create (first_time) ** Invoke db:load_config (first_time) ** Execute (dry run) db:load_config ** Invoke rails_env (first_time) ** Execute (dry run) rails_env ** Execute (dry run) db:create
I'm running rails 3.2.13 and rake 10.0.4
You can write a custom rake task which will do require task given below
desc "Rake db:create with SQL logging" task :db_create => :environment do Rails.logger.level = Logger::DEBUG `rake db:create` end
It will gives your required output.