[英]Rake task for installing gem migrations executing only once
為什么這個rake任務
gems = %w(gem1 gem2 gem3)
namespace :gems do
namespace :install do
desc "Runs install:migrations for all gems"
task :migrations do
gems.each do |gem_name|
print "\nInstalling migrations for the #{gem_name} gem...\n"
Rake::Task["#{gem_name}:install:migrations"].invoke
end
print "\n\nGem migrations installed."
end
end
end
實際上只運行第一組遷移,無論我使用的gems / gem order / random調用reenable?
Installing migrations for the gem1 gem...
Copied migration whatever from gem1
Copied migration whatever from gem1
Copied migration whatever from gem1
Copied migration whatever from gem1
Installing migrations for the gem2 gem...
(nothing)
Installing migrations for the gem3 gem...
(nothing)
Gem migrations installed.
invoke
方法僅“按需”運行,這基本上意味着一旦運行一次,除非重新啟用,否則它不會再次運行。
您可以撥打.reenable
后每個.invoke
將其復位,或使用.execute
命令來運行任務。
使用.execute
的警告是,如果你擁有它們,它將不會運行任務的依賴項。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.