开发者

Rake - halt on Rails migrate errors?

Is there a way to make rake halt execution when invoking the Rails migration tasks? Right now it runs straight through attempting each one. What I really want is to attempt drop开发者_如何转开发, then attempt create, and if either of those are successful, then run migrate, then seed if that is successful, stop and display an error if any failures.

I've tried invoke on each task, testing the result but, that doesn't seem to be right either.

Thanks.

task :fresh_start => [
  'db:drop',
  'db:create',
  'db:migrate',
  'db:seed'] do
end


By default Rake will stop at the first exception raised. For instance the following will never print "That".

task :this do
  puts "This"
  raise "Fail!"
end

task :that do
  puts "That"
end

task :default => [:this,:that]

Isn't that what you'd like ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜