aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJuan M. Cuello <juanmacuello@gmail.com>2011-12-12 15:44:16 -0300
committerJuan M. Cuello <juanmacuello@gmail.com>2011-12-19 18:20:17 -0300
commit626c881863bbcd600789d8372c34bd3650fcb227 (patch)
tree6ea5d8a9ad21d7833efa8a534231358da382b67a /activerecord
parent3c1884e7dd77d8f33f86e96fd7e4190c4a301133 (diff)
downloadrails-626c881863bbcd600789d8372c34bd3650fcb227.tar.gz
rails-626c881863bbcd600789d8372c34bd3650fcb227.tar.bz2
rails-626c881863bbcd600789d8372c34bd3650fcb227.zip
Fix database tasks in test namespace.
This is mostly the same as 876bade5999c51f5031861f703933d50e48512ff that was reverted due to test failures, but now with a correction.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/railties/databases.rake31
1 files changed, 22 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake
index 0d1d9845ae..199eee4359 100644
--- a/activerecord/lib/active_record/railties/databases.rake
+++ b/activerecord/lib/active_record/railties/databases.rake
@@ -446,26 +446,39 @@ db_namespace = namespace :db do
end
namespace :test do
- # desc "Recreate the test database from the current schema.rb"
+
+ # desc "Recreate the test database from the current schema"
task :load => 'db:test:purge' do
- ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test'])
- ActiveRecord::Schema.verbose = false
- db_namespace["schema:load"].invoke if ActiveRecord::Base.schema_format == :ruby
+ case ActiveRecord::Base.schema_format
+ when :ruby
+ db_namespace["test:load_schema"].invoke
+ when :sql
+ db_namespace["test:load_structure"].invoke
+ end
+ end
+ # desc "Recreate the test database from an existent structure.sql file"
+ task :load_structure => 'db:test:purge' do
begin
old_env, ENV['RAILS_ENV'] = ENV['RAILS_ENV'], 'test'
- db_namespace["structure:load"].invoke if ActiveRecord::Base.schema_format == :sql
+ db_namespace["structure:load"].invoke
ensure
ENV['RAILS_ENV'] = old_env
end
+ end
+ # desc "Recreate the test database from an existent schema.rb file"
+ task :load_schema => 'db:test:purge' do
+ ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test'])
+ ActiveRecord::Schema.verbose = false
+ db_namespace["schema:load"].invoke
end
- # desc "Recreate the test database from the current environment's database schema"
- task :clone => %w(db:schema:dump db:test:load)
+ # desc "Recreate the test database from a fresh schema.rb file"
+ task :clone => %w(db:schema:dump db:test:load_schema)
- # desc "Recreate the test databases from the structure.sql file"
- task :clone_structure => [ "db:structure:dump", "db:test:load" ]
+ # desc "Recreate the test database from a fresh structure.sql file"
+ task :clone_structure => [ "db:structure:dump", "db:test:load_structure" ]
# desc "Empty the test database"
task :purge => :environment do