The Rake task to install gem migration runs only once

Why is this rake task

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 

actually starts the first set of migrations, regardless of how to use the gems / gem ordering / random calls for reuse that I use?

 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. 
+4
source share
1 answer

The invoke method only works "as needed", which basically means that once it is launched once, it will not start again if it is not reconnected.

You can call .reenable after each .invoke until reset, or use the .execute command to start the task.

The .execute with .execute is that it will not run dependencies for the task if you have them.

Why can't Rake invoke multiple tasks sequentially?

How to run Rake tasks from Rake tasks?

+5
source

Source: https://habr.com/ru/post/1439468/


All Articles