现在我正在开发一个Rails应用程序与安装在发动机。Rake任务的自动迁移引擎迁移
我thoughed这将是一个好主意,编写一个耙TAST,这将迁移从引擎复制并运行rake db:migrate。但是,如果我在engine-Arry(见下文)中只使用一个引擎运行rake任务,则rake tast将复制引擎中的迁移并迁移数据库。但是如果我将另一个引擎添加到数组中,rake-Task将不再工作。
namespace :work_in_progress do
desc 'Migrate the engines db tables'
task migrate_migrations_from_engines: :environment do
# The array with the available engines (just add the new engine here)
engines = [
'engine_one',
'engine_two'
]
puts 'Migrating migrations from engines...'
engines.each do |engine|
puts 'Copying migrations from ' + engine
Rake::Task[engine + ':install:migrations'].invoke
end
puts 'Migrating the database...'
Rake::Task['db:migrate'].invoke
puts 'Done...'
end
end
如何改进上面的脚本,以便可以迁移多个引擎? 是否有解决此问题的其他脚本(复制从引擎迁移并运行它们?)?
非常感谢!
菲利普
您是否收到错误? – cortex
没有错误。只有“放入”写入控制台,但没有其他事情发生。 – pmuens
尝试'执行'而不是'调用'。 – cortex