Skip to content

Instantly share code, notes, and snippets.

@ukstudio
Created July 20, 2012 06:21
Show Gist options
  • Save ukstudio/3149025 to your computer and use it in GitHub Desktop.
Save ukstudio/3149025 to your computer and use it in GitHub Desktop.
redo
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