只执行一次的gem migrations安装Rake任务

4
为什么这个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排序/随机调用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.
1个回答

5

好的,但是关于问题,需要重新启用“railties:install:migrations”每个Rake::Task["#{gem}:install:migrations"].execute或调用一次,然后一切都会正常。 - Bruno Guerra

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接