diff options
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/railties/databases.rake | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index 3f7b56e6b8..128223115c 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -166,12 +166,7 @@ db_namespace = namespace :db do end # 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 - + task :abort_if_pending_migrations => 'db:test:load_schema' do pending_migrations = ActiveRecord::Migrator.open(ActiveRecord::Migrator.migrations_paths).pending_migrations if pending_migrations.any? @@ -181,9 +176,6 @@ 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)' @@ -355,7 +347,7 @@ db_namespace = namespace :db do end # desc 'Check for pending migrations and load the test schema' - task :prepare => 'db:abort_if_pending_migrations' do + task :prepare do unless ActiveRecord::Base.configurations.blank? db_namespace['test:load'].invoke end @@ -391,5 +383,5 @@ namespace :railties do end end -task 'test:prepare' => 'db:test:prepare' +task 'test:prepare' => ['db:test:prepare', 'db:abort_if_pending_migrations'] |