Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
jeremy committed Jul 5, 2006
1 parent bffb29f commit 3398f74
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions railties/CHANGELOG
@@ -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:
Expand Down
10 changes: 5 additions & 5 deletions railties/lib/tasks/databases.rake
Expand Up @@ -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 }
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 3398f74

Please sign in to comment.