Permalink
Browse files

db:test:clone should remove existing tables before reloading the sche…

…ma. Closes #5607.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4557 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent bffb29f commit 3398f74db153327a296bfe845a3423437ced3b97 @jeremy jeremy committed Jul 5, 2006
Showing with 7 additions and 5 deletions.
  1. +2 −0 railties/CHANGELOG
  2. +5 −5 railties/lib/tasks/databases.rake
View
@@ -1,5 +1,7 @@
*SVN*
+* db:test:clone should remove existing tables before reloading the schema. #5607 [sveit@tradeharbor.com]
+
* Fixed migration generation for class names like ACLController #5197 [brad@madriska.com]
* Added show_source_list and show_call_stack to breakpoints to make it easier to get context #5476 [takiuchi@drecom.co.jp]. Examples:
@@ -36,7 +36,7 @@ namespace :db do
desc "Dump the database structure to a SQL file"
task :dump => :environment do
abcs = ActiveRecord::Base.configurations
- case abcs[RAILS_ENV]["adapter"]
+ case abcs[RAILS_ENV]["adapter"]
when "mysql", "oci", "oracle"
ActiveRecord::Base.establish_connection(abcs[RAILS_ENV])
File.open("db/#{RAILS_ENV}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump }
@@ -54,7 +54,7 @@ namespace :db do
when "sqlserver"
`scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /f db\\#{RAILS_ENV}_structure.sql /q /A /r`
`scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /F db\ /q /A /r`
- else
+ else
raise "Task not supported by '#{abcs["test"]["adapter"]}'"
end
@@ -66,13 +66,13 @@ namespace :db do
namespace :test do
desc "Recreate the test database from the current environment's database schema"
- task :clone => "db:schema:dump" do
+ task :clone => %w(db:schema:dump db:test:purge) do
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test'])
ActiveRecord::Schema.verbose = false
Rake::Task["db:schema:load"].invoke
end
-
+
desc "Recreate the test databases from the development structure"
task :clone_structure => [ "db:structure:dump", "db:test:purge" ] do
abcs = ActiveRecord::Base.configurations
@@ -98,7 +98,7 @@ namespace :db do
IO.readlines("db/#{RAILS_ENV}_structure.sql").join.split(";\n\n").each do |ddl|
ActiveRecord::Base.connection.execute(ddl)
end
- else
+ else
raise "Task not supported by '#{abcs["test"]["adapter"]}'"
end
end

0 comments on commit 3398f74

Please sign in to comment.