Skip to content

Instantly share code, notes, and snippets.

@knowuh
Created April 28, 2011 18:59
Show Gist options
  • Save knowuh/947041 to your computer and use it in GitHub Desktop.
Save knowuh/947041 to your computer and use it in GitHub Desktop.
Where did these migrations come from?
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