diff options
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/railties/databases.rake | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index 78afed5e91..3f7b56e6b8 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -167,6 +167,11 @@ db_namespace = namespace :db do # desc "Raises an error if there are pending migrations" task :abort_if_pending_migrations => [:environment, :load_config] do + env = Rails.env + ActiveRecord::SchemaMigration.class_eval do + establish_connection 'development' + end + pending_migrations = ActiveRecord::Migrator.open(ActiveRecord::Migrator.migrations_paths).pending_migrations if pending_migrations.any? @@ -176,6 +181,9 @@ db_namespace = namespace :db do end abort %{Run `rake db:migrate` to update your database then try again.} end + ActiveRecord::SchemaMigration.class_eval do + establish_connection env + end end desc 'Create the database, load the schema, and initialize with the seed data (use db:reset to also drop the db first)' |