Created
March 31, 2017 19:41
-
-
Save ragesoss/793b4c1b1205da9a101e2dc076126fe6 to your computer and use it in GitHub Desktop.
Add version numbers to pre-5.0 Ruby on Rails ActiveRecord migrations.
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
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment