From ff7ab3bc78abc3e8439a57ef7d755c5aa5b069f4 Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Sun, 29 Dec 2013 11:05:04 +0000 Subject: 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". --- activerecord/lib/active_record/railtie.rb | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'activerecord/lib/active_record/railtie.rb') diff --git a/activerecord/lib/active_record/railtie.rb b/activerecord/lib/active_record/railtie.rb index 2a8cd83285..ec85b3c843 100644 --- a/activerecord/lib/active_record/railtie.rb +++ b/activerecord/lib/active_record/railtie.rb @@ -31,22 +31,15 @@ module ActiveRecord config.active_record.use_schema_cache_dump = true + config.active_record.maintain_test_schema = true config.eager_load_namespaces << ActiveRecord rake_tasks do require "active_record/base" - ActiveRecord::Tasks::DatabaseTasks.seed_loader = Rails.application - ActiveRecord::Tasks::DatabaseTasks.env = Rails.env - namespace :db do task :load_config do - ActiveRecord::Tasks::DatabaseTasks.db_dir = Rails.application.config.paths["db"].first - ActiveRecord::Tasks::DatabaseTasks.migrations_paths = Rails.application.paths['db/migrate'].to_a - ActiveRecord::Tasks::DatabaseTasks.fixtures_path = File.join Rails.root, 'test', 'fixtures' - ActiveRecord::Tasks::DatabaseTasks.root = Rails.root - configuration = if ENV["DATABASE_URL"] { Rails.env => ENV["DATABASE_URL"] } else -- cgit v1.2.3