Dir[Rails.root.join("app", "models", "enhancements", "*.rb")].each do |path|
  name = File.basename(path, ".rb")
  require "enhancements/#{name}"
end

# We conditionally apply the model enhancements (at the time of writing, only one exists) since the model change
# was breaking a migration when spinning up a clean install.
#
# ==  SwapMagicEverythingPermissionsForRealOnes: migrating ======================
# rake aborted!
# An error has occurred, all later migrations canceled:
#
# Mysql2::Error: Table 'signonotron2_development.supported_permissions' doesn't exist: SHOW FIELDS FROM `supported_permissions`
#
unless ( File.basename($0) == "rake" && ARGV.include?("db:migrate") )
  Dir[Rails.root.join("app", "models", "enhancements", "*.rb")].each do |path|
    name = File.basename(path, ".rb")
    require "enhancements/#{name}"
  end
end
Fix migrations failure for clean spinup
Fix migrations failure for clean spinup

$ bundle exec rake db:create db:migrate
…

==  SwapMagicEverythingPermissionsForRealOnes: migrating ======================
rake aborted!
An error has occurred, all later migrations canceled:

Mysql2::Error: Table 'signonotron2_development.supported_permissions' doesn't exist: SHOW FIELDS FROM `supported_permissions`

936046ec added an initializer which modifies the Doorkeeper::Application
model. That class is also modified in the migration
20120626094255_swap_magic_everything_permissions_for_real_ones.rb, so we
were seeing the above failure.