diff options
author | Jon Leighton <j@jonathanleighton.com> | 2013-12-29 11:05:04 +0000 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2014-01-02 13:49:00 +0000 |
commit | ff7ab3bc78abc3e8439a57ef7d755c5aa5b069f4 (patch) | |
tree | 5ad6aed8ee454c320967d767229debde268da2e2 /activerecord/lib/active_record/migration.rb | |
parent | a1d0c0fa3d8ca97edc8f2a1d6ba96af19221dbad (diff) | |
download | rails-ff7ab3bc78abc3e8439a57ef7d755c5aa5b069f4.tar.gz rails-ff7ab3bc78abc3e8439a57ef7d755c5aa5b069f4.tar.bz2 rails-ff7ab3bc78abc3e8439a57ef7d755c5aa5b069f4.zip |
Automatically maintain test database schema
* Move check from generated helper to test_help.rb, so that all
applications can benefit
* Rather than just raising when the test schema has pending migrations,
try to load in the schema and only raise if there are pending
migrations afterwards
* Opt out of the check by setting
config.active_record.maintain_test_schema = false
* Deprecate db:test:* tasks. The test helper is now fully responsible
for maintaining the test schema, so we don't need rake tasks for this.
This is also a speed improvement since we're no longer reloading the
test database on every call to "rake test".
Diffstat (limited to 'activerecord/lib/active_record/migration.rb')
-rw-r--r-- | activerecord/lib/active_record/migration.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 7d7e97e6c9..fc84b907a5 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -389,6 +389,19 @@ module ActiveRecord raise ActiveRecord::PendingMigrationError if ActiveRecord::Migrator.needs_migration? end + def load_schema_if_pending! + if ActiveRecord::Migrator.needs_migration? + ActiveRecord::Tasks::DatabaseTasks.load_schema + check_pending! + end + end + + def maintain_test_schema! # :nodoc: + if ActiveRecord::Base.maintain_test_schema + suppress_messages { load_schema_if_pending! } + end + end + def method_missing(name, *args, &block) # :nodoc: (delegate || superclass.delegate).send(name, *args, &block) end |