Skip to content

Instantly share code, notes, and snippets.

View ragesoss's full-sized avatar

Sage Ross ragesoss

View GitHub Profile
@ragesoss
ragesoss / add_versions_to_old_migrations.rb
Created March 31, 2017 19:41
Add version numbers to pre-5.0 Ruby on Rails ActiveRecord migrations.
# Run from db/migrate to fix your old un-versioned migrations, so that they don't break on Rails 5.1
Dir.glob('*').each do |migration|
versioned_migration = File.read(migration).gsub("< ActiveRecord::Migration\n", "< ActiveRecord::Migration[4.2]\n")
File.open(migration, 'w') do |output|
output << versioned_migration
end
end