Created
January 6, 2014 17:28
detect inconsistencies between migrations in codebase and database
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
db_versions = ActiveRecord::Base.connection.execute('select * from schema_migrations').map {|r| r['version']} | |
migrations = Dir.glob('db/migrate/*').map {|f| File.basename(f).split('_').first } | |
unrun_migrations = migrations.reject {|m| db_versions.include?(m) } | |
unreverted_migrations = db_versions.reject {|v| migrations.include?(v) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment