# Running migrations through rake task

**URL:** <https://www.ruby-forum.com/t/running-migrations-through-rake-task/141392>\
**Category:** Rails\
**Created:** [June 25, 2008, 11:41am UTC](https://www.ruby-forum.com/t/running-migrations-through-rake-task/141392 "2008-06-25T11:41:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MohsinHijazee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e68b1a/32.png) [@MohsinHijazee](https://www.ruby-forum.com/u/MohsinHijazee)\
**Post date:** [June 25, 2008, 11:41am UTC](https://www.ruby-forum.com/t/running-migrations-through-rake-task/141392/1 "2008-06-25T11:41:11Z")

</div>

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  
[  
‘development’,  
‘test’,  
‘production’  
].each do |environment|  
ENV[‘RAILS\_ENV’] = environment  
Rake::Task[‘db:migrate’].execute(’’)  
system “RAILS\_ENV=#{environment} rake db:migrate”  
end  
end

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?

Regards,  
Mohsin
