Created
November 12, 2015 16:07
-
-
Save bf4/397d025b7243c69b99fd to your computer and use it in GitHub Desktop.
Squash Rails migrations in this one easy step
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
#!/usr/bin/env bash | |
git ls-files db/migrate/*.rb | sort | tail -1 | \ | |
ruby -e "schema_version=STDIN.read[/\d+/]; init_schema=%(db/migrate/#{schema_version}_init_schema.rb); | |
%x(git rm -f db/migrate/*.rb; | |
mkdir db/migrate; | |
git mv db/schema.rb #{init_schema}; | |
rake db:migrate; | |
git add db/schema.rb; git commit -m 'Squashed migrations')" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment