[ rake ] migrate database

rake db:create && rake db:migrate && rake db:seed

NOTE : need rakefile, or Rakefile, or rakefile.rb, or Rakefile.rb

List all rake tasks

rake -T

Generating rake tasks

The code will be generated to lib/tasks/

i.e. lib/tasks/app/test.rake

namespace :app do

desc 'whatever'

task :test, [:params1] do |_, args|

puts args[:params1]

puts #{func1(args)}

end

def func1(args)

return if args[:params1].blank?

"args[:params1]"

end

end
rake app::test[50]

rake options : –trace

ref : http://railsguides.net/how-to-generate-rake-task/

, https://edelpero.svbtle.com/everything-you-always-wanted-to-know-about-writing-good-rake-tasks-but-were-afraid-to-ask

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s