Running migrations through rake task

I want to run all the migrations on all my databases. For this, I have
a task called run_migrations. Consider this code:

desc 'Runs migrations on all databases'
  task :run_migrations => :environment do
    ].each do |environment|
      ENV['RAILS_ENV'] = environment
      system "RAILS_ENV=#{environment} rake db:migrate"

This runs migrations only for the development database because further
calls to execute the task are ignored. Is there any way to force the
execution of the Rake task?