Created
July 20, 2012 06:21
-
-
Save ukstudio/3149025 to your computer and use it in GitHub Desktop.
redo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :db do | |
desc "Redo target timestamp newer migration." | |
task :redo_timestamp => :environment do | |
timestamp = ENV['TIMESTAMP'] | |
files = Dir.glob("db/migrate/*.rb").map {|file| | |
md = file.split(File::SEPARATOR).last.match(/(^\d+)_\w+\.rb/) | |
[md[0], md[1].to_i] | |
}.select{|match| match[1] > timestamp.to_i }.map{|match| match[0]} | |
ENV['STEP'] = files.size.to_s | |
Rake::Task['db:migrate:redo'].invoke | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment