mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
db:test:clone should remove existing tables before reloading the schema. Closes #5607.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4557 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
bffb29fb7d
commit
3398f74db1
2 changed files with 7 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue