Skip to content

Instantly share code, notes, and snippets.

@wbotelhos
Created June 4, 2017 19:26
Show Gist options
  • Save wbotelhos/f6ffaa78944fabbe8681904d4f417993 to your computer and use it in GitHub Desktop.
Save wbotelhos/f6ffaa78944fabbe8681904d4f417993 to your computer and use it in GitHub Desktop.
Migration Rename
# frozen_string_literal: true
namespace :migration do
task rename: :environment do
Dir['db/migrate/*'].sort.each do |filename|
sleep 1
File.rename(
filename,
filename.sub(/[0-9]+/, Time.current.strftime('%Y%m%d%H%M%S'))
)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment