From 1c2ad03f194e1bbc062a1fe684a5d3804d09a32f Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 29 Mar 2013 19:19:23 -0700 Subject: ensure the schema checking is done in the dev connection --- activerecord/lib/active_record/railties/databases.rake | 8 ++++++++ 1 file changed, 8 insertions(+) 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)' -- cgit v1.2.3