diff options
author | Juan M. Cuello <juanmacuello@gmail.com> | 2011-12-12 15:44:16 -0300 |
---|---|---|
committer | Juan M. Cuello <juanmacuello@gmail.com> | 2011-12-19 13:52:27 -0300 |
commit | 876bade5999c51f5031861f703933d50e48512ff (patch) | |
tree | a9074f176e93ebe566a48fc799e40941985b9d2b /activerecord/lib/active_record | |
parent | 4012fcff22e4fe7833aae53b98e3ca9acfe3d3ad (diff) | |
download | rails-876bade5999c51f5031861f703933d50e48512ff.tar.gz rails-876bade5999c51f5031861f703933d50e48512ff.tar.bz2 rails-876bade5999c51f5031861f703933d50e48512ff.zip |
Fix database tasks in test namespace.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/railties/databases.rake | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index 0d1d9845ae..a657fde6a8 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -446,26 +446,37 @@ 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 + 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 |