Created
April 28, 2011 18:59
-
-
Save knowuh/947041 to your computer and use it in GitHub Desktop.
Where did these migrations come from?
This file contains hidden or 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
def migrations_without_files | |
results = ActiveRecord::Base.connection.execute("select * from schema_migrations;") | |
migrations = [] | |
results.each { |r| migrations << r } | |
migrations.flatten!.map!{ |m| m.gsub(/[^\d]*/,"")} | |
migrate_path = File.join(RAILS_ROOT,"db","migrate","*.rb") | |
files = Dir.glob(migrate_path).map{ |f| f.gsub(/.*\/(\d+)_.*/, '\1') } | |
missing_files = migrations.reject { |m| files.include?(m) } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment