diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-04-03 13:19:26 -0400 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-04-03 13:19:26 -0400 |
commit | 76a80918b09f98c884094f82417865b8398373e9 (patch) | |
tree | 9a7a36875ec213d0921447610a5383c203f6103c /activerecord/lib | |
parent | 999835a8e5a34afb41af54f3cb14562a6c759a04 (diff) | |
download | rails-76a80918b09f98c884094f82417865b8398373e9.tar.gz rails-76a80918b09f98c884094f82417865b8398373e9.tar.bz2 rails-76a80918b09f98c884094f82417865b8398373e9.zip |
check pending migrations against the test db
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'] |