Created
May 14, 2011 02:33
-
-
Save AquaGeek/971699 to your computer and use it in GitHub Desktop.
Rails Lighthouse ticket #5412
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From ddafb51642100709d05e1194a5442547dd55a968 Mon Sep 17 00:00:00 2001 | |
From: Nick Gauthier <nick@smartlogicsolutions.com> | |
Date: Thu, 19 Aug 2010 14:31:30 -0400 | |
Subject: [PATCH] ActiveRecord schema_format :sql now mimics the behavior of :ruby. | |
--- | |
.../lib/active_record/railties/databases.rake | 63 ++++++++++++++----- | |
1 files changed, 46 insertions(+), 17 deletions(-) | |
diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake | |
index ae605d3..1855cb4 100644 | |
--- a/activerecord/lib/active_record/railties/databases.rake | |
+++ b/activerecord/lib/active_record/railties/databases.rake | |
@@ -139,6 +139,7 @@ namespace :db do | |
ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true | |
ActiveRecord::Migrator.migrate("db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil) | |
Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby | |
+ Rake::Task["db:structure:dump"].invoke if ActiveRecord::Base.schema_format == :sql | |
end | |
namespace :migrate do | |
@@ -162,6 +163,7 @@ namespace :db do | |
raise "VERSION is required" unless version | |
ActiveRecord::Migrator.run(:up, "db/migrate/", version) | |
Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby | |
+ Rake::Task["db:structure:dump"].invoke if ActiveRecord::Base.schema_format == :sql | |
end | |
# desc 'Runs the "down" for a given migration VERSION.' | |
@@ -170,6 +172,7 @@ namespace :db do | |
raise "VERSION is required" unless version | |
ActiveRecord::Migrator.run(:down, "db/migrate/", version) | |
Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby | |
+ Rake::Task["db:structure:dump"].invoke if ActiveRecord::Base.schema_format == :sql | |
end | |
desc "Display status of migrations" | |
@@ -208,6 +211,7 @@ namespace :db do | |
step = ENV['STEP'] ? ENV['STEP'].to_i : 1 | |
ActiveRecord::Migrator.rollback('db/migrate/', step) | |
Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby | |
+ Rake::Task["db:structure:dump"].invoke if ActiveRecord::Base.schema_format == :sql | |
end | |
# desc 'Pushes the schema to the next version (specify steps w/ STEP=n).' | |
@@ -215,6 +219,7 @@ namespace :db do | |
step = ENV['STEP'] ? ENV['STEP'].to_i : 1 | |
ActiveRecord::Migrator.forward('db/migrate/', step) | |
Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby | |
+ Rake::Task["db:structure:dump"].invoke if ActiveRecord::Base.schema_format == :sql | |
end | |
# desc 'Drops and recreates the database from db/schema.rb for the current environment and loads the seeds.' | |
@@ -271,7 +276,13 @@ namespace :db do | |
end | |
desc 'Create the database, load the schema, and initialize with the seed data (use db:reset to also drop the db first)' | |
- task :setup => [ 'db:create', 'db:schema:load', 'db:seed' ] | |
+ task :setup do | |
+ Rake::Task["db:create"].invoke | |
+ Rake::Task["db:schema:load"].invoke if ActiveRecord::Base.schema_format == :ruby | |
+ Rake::Task["db:structure:load"].invoke if ActiveRecord::Base.schema_format == :sql | |
+ Rake::Task["db:seed"].invoke | |
+ end | |
+ | |
desc 'Load the seed data from db/seeds.rb' | |
task :seed => 'db:abort_if_pending_migrations' do | |
@@ -345,7 +356,7 @@ namespace :db do | |
case abcs[Rails.env]["adapter"] | |
when /mysql/, "oci", "oracle" | |
ActiveRecord::Base.establish_connection(abcs[Rails.env]) | |
- File.open("#{Rails.root}/db/#{Rails.env}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump } | |
+ File.open("#{Rails.root}/db/structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump } | |
when "postgresql" | |
ENV['PGHOST'] = abcs[Rails.env]["host"] if abcs[Rails.env]["host"] | |
ENV['PGPORT'] = abcs[Rails.env]["port"].to_s if abcs[Rails.env]["port"] | |
@@ -354,26 +365,39 @@ namespace :db do | |
unless search_path.blank? | |
search_path = search_path.split(",").map{|search_path| "--schema=#{search_path.strip}" }.join(" ") | |
end | |
- `pg_dump -i -U "#{abcs[Rails.env]["username"]}" -s -x -O -f db/#{Rails.env}_structure.sql #{search_path} #{abcs[Rails.env]["database"]}` | |
+ `pg_dump -i -U "#{abcs[Rails.env]["username"]}" -s -x -O -f db/structure.sql #{search_path} #{abcs[Rails.env]["database"]}` | |
raise "Error dumping database" if $?.exitstatus == 1 | |
when "sqlite", "sqlite3" | |
dbfile = abcs[Rails.env]["database"] || abcs[Rails.env]["dbfile"] | |
- `#{abcs[Rails.env]["adapter"]} #{dbfile} .schema > db/#{Rails.env}_structure.sql` | |
+ `#{abcs[Rails.env]["adapter"]} #{dbfile} .schema > db/structure.sql` | |
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\\structure.sql /q /A /r` | |
`scptxfr /s #{abcs[Rails.env]["host"]} /d #{abcs[Rails.env]["database"]} /I /F db\ /q /A /r` | |
when "firebird" | |
set_firebird_env(abcs[Rails.env]) | |
db_string = firebird_db_string(abcs[Rails.env]) | |
- sh "isql -a #{db_string} > #{Rails.root}/db/#{Rails.env}_structure.sql" | |
+ sh "isql -a #{db_string} > #{Rails.root}/db/structure.sql" | |
else | |
raise "Task not supported by '#{abcs["test"]["adapter"]}'" | |
end | |
if ActiveRecord::Base.connection.supports_migrations? | |
- File.open("#{Rails.root}/db/#{Rails.env}_structure.sql", "a") { |f| f << ActiveRecord::Base.connection.dump_schema_information } | |
+ File.open("#{Rails.root}/db/structure.sql", "a") { |f| f << ActiveRecord::Base.connection.dump_schema_information } | |
end | |
end | |
+ | |
+ desc "Load the database structure from an SQL file" | |
+ task :load => :environment do | |
+ file = File.join(Rails.root, 'db', 'structure.sql') | |
+ if File.exists?(file) | |
+ IO.readlines(file).join.split("\n\n").each do |sql_statement| | |
+ ActiveRecord::Base.connection.execute(sql_statement) | |
+ end | |
+ else | |
+ abort %{#{file} doesn't exist yet. Run "rake db:migrate" to create it then try again. If you do not intend to use a database, you should instead alter #{Rails.root}/config/boot.rb to limit the frameworks that will be loaded} | |
+ end | |
+ end | |
+ | |
end | |
namespace :test do | |
@@ -381,41 +405,46 @@ namespace :db do | |
task :load => 'db:test:purge' do | |
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test']) | |
ActiveRecord::Schema.verbose = false | |
- Rake::Task["db:schema:load"].invoke | |
+ Rake::Task["db:schema:load"].invoke if ActiveRecord::Base.schema_format == :ruby | |
+ Rake::Task["db:structure:load"].invoke if ActiveRecord::Base.schema_format == :sql | |
end | |
# desc "Recreate the test database from the current environment's database schema" | |
- task :clone => %w(db:schema:dump db:test:load) | |
+ task :clone do | |
+ Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby | |
+ Rake::Task["db:structure:dump"].invoke if ActiveRecord::Base.schema_format == :sql | |
+ Rake::Task["db:test:load"].invoke | |
+ end | |
- # desc "Recreate the test databases from the development structure" | |
+ # desc "Recreate the test databases from the database structure" | |
task :clone_structure => [ "db:structure:dump", "db:test:purge" ] do | |
abcs = ActiveRecord::Base.configurations | |
case abcs["test"]["adapter"] | |
when /mysql/ | |
ActiveRecord::Base.establish_connection(:test) | |
ActiveRecord::Base.connection.execute('SET foreign_key_checks = 0') | |
- IO.readlines("#{Rails.root}/db/#{Rails.env}_structure.sql").join.split("\n\n").each do |table| | |
+ IO.readlines("#{Rails.root}/db/structure.sql").join.split("\n\n").each do |table| | |
ActiveRecord::Base.connection.execute(table) | |
end | |
when "postgresql" | |
ENV['PGHOST'] = abcs["test"]["host"] if abcs["test"]["host"] | |
ENV['PGPORT'] = abcs["test"]["port"].to_s if abcs["test"]["port"] | |
ENV['PGPASSWORD'] = abcs["test"]["password"].to_s if abcs["test"]["password"] | |
- `psql -U "#{abcs["test"]["username"]}" -f #{Rails.root}/db/#{Rails.env}_structure.sql #{abcs["test"]["database"]}` | |
+ `psql -U "#{abcs["test"]["username"]}" -f #{Rails.root}/db/structure.sql #{abcs["test"]["database"]}` | |
when "sqlite", "sqlite3" | |
dbfile = abcs["test"]["database"] || abcs["test"]["dbfile"] | |
- `#{abcs["test"]["adapter"]} #{dbfile} < #{Rails.root}/db/#{Rails.env}_structure.sql` | |
+ `#{abcs["test"]["adapter"]} #{dbfile} < #{Rails.root}/db/structure.sql` | |
when "sqlserver" | |
- `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{Rails.env}_structure.sql` | |
+ `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\structure.sql` | |
when "oci", "oracle" | |
ActiveRecord::Base.establish_connection(:test) | |
- IO.readlines("#{Rails.root}/db/#{Rails.env}_structure.sql").join.split(";\n\n").each do |ddl| | |
+ IO.readlines("#{Rails.root}/db/structure.sql").join.split(";\n\n").each do |ddl| | |
ActiveRecord::Base.connection.execute(ddl) | |
end | |
when "firebird" | |
set_firebird_env(abcs["test"]) | |
db_string = firebird_db_string(abcs["test"]) | |
- sh "isql -i #{Rails.root}/db/#{Rails.env}_structure.sql #{db_string}" | |
+ sh "isql -i #{Rails.root}/db/structure.sql #{db_string}" | |
else | |
raise "Task not supported by '#{abcs["test"]["adapter"]}'" | |
end | |
@@ -438,7 +467,7 @@ namespace :db do | |
when "sqlserver" | |
dropfkscript = "#{abcs["test"]["host"]}.#{abcs["test"]["database"]}.DP1".gsub(/\\/,'-') | |
`osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{dropfkscript}` | |
- `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{Rails.env}_structure.sql` | |
+ `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\structure.sql` | |
when "oci", "oracle" | |
ActiveRecord::Base.establish_connection(:test) | |
ActiveRecord::Base.connection.structure_drop.split(";\n\n").each do |ddl| | |
-- | |
1.7.0.4 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- databases.rake.orig 2011-03-31 17:01:27.000000000 -0400 | |
+++ databases.rake 2011-04-06 11:27:49.000000000 -0400 | |
@@ -111,6 +111,7 @@ | |
ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true | |
ActiveRecord::Migrator.migrate("db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil) | |
Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby | |
+ Rake::Task["db:structure:dump"].invoke if ActiveRecord::Base.schema_format == :sql | |
end | |
namespace :migrate do | |
@@ -134,6 +135,7 @@ | |
raise "VERSION is required" unless version | |
ActiveRecord::Migrator.run(:up, "db/migrate/", version) | |
Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby | |
+ Rake::Task["db:structure:dump"].invoke if ActiveRecord::Base.schema_format == :sql | |
end | |
desc 'Runs the "down" for a given migration VERSION.' | |
@@ -142,6 +144,7 @@ | |
raise "VERSION is required" unless version | |
ActiveRecord::Migrator.run(:down, "db/migrate/", version) | |
Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby | |
+ Rake::Task["db:structure:dump"].invoke if ActiveRecord::Base.schema_format == :sql | |
end | |
end | |
@@ -150,10 +153,14 @@ | |
step = ENV['STEP'] ? ENV['STEP'].to_i : 1 | |
ActiveRecord::Migrator.rollback('db/migrate/', step) | |
Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby | |
+ Rake::Task["db:structure:dump"].invoke if ActiveRecord::Base.schema_format == :sql | |
end | |
- desc 'Drops and recreates the database from db/schema.rb for the current environment and loads the seeds.' | |
- task :reset => [ 'db:drop', 'db:setup' ] | |
+ desc 'Drops and recreates the database from db/schema.rb or structure.sql for the current environment and loads the seeds.' | |
+ task :reset => :environment do | |
+ Rake::Task["db:drop"].invoke | |
+ Rake::Task["db:setup"].invoke | |
+ end | |
desc "Retrieves the charset for the current environment's database" | |
task :charset => :environment do | |
@@ -203,7 +210,12 @@ | |
end | |
desc 'Create the database, load the schema, and initialize with the seed data' | |
- task :setup => [ 'db:create', 'db:schema:load', 'db:seed' ] | |
+ task :setup => :environment do | |
+ Rake::Task["db:create"].invoke | |
+ Rake::Task["db:schema:load"].invoke if ActiveRecord::Base.schema_format == :ruby | |
+ Rake::Task["db:structure:load"].invoke if ActiveRecord::Base.schema_format == :sql | |
+ Rake::Task["db:seed"].invoke | |
+ end | |
desc 'Load the seed data from db/seeds.rb' | |
task :seed => :environment do | |
@@ -276,79 +288,86 @@ | |
case abcs[RAILS_ENV]["adapter"] | |
when /^mysql/, "oci", "oracle" | |
ActiveRecord::Base.establish_connection(abcs[RAILS_ENV]) | |
- File.open("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump } | |
+ File.open("#{RAILS_ROOT}/db/structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump } | |
when "postgresql" | |
ENV['PGHOST'] = abcs[RAILS_ENV]["host"] if abcs[RAILS_ENV]["host"] | |
ENV['PGPORT'] = abcs[RAILS_ENV]["port"].to_s if abcs[RAILS_ENV]["port"] | |
ENV['PGPASSWORD'] = abcs[RAILS_ENV]["password"].to_s if abcs[RAILS_ENV]["password"] | |
+ ENV['PGUSER'] = abcs[RAILS_ENV]["username"].to_s if abcs[RAILS_ENV]["username"] | |
search_path = abcs[RAILS_ENV]["schema_search_path"] | |
search_path = "--schema=#{search_path}" if search_path | |
- `pg_dump -i -U "#{abcs[RAILS_ENV]["username"]}" -s -x -O -f db/#{RAILS_ENV}_structure.sql #{search_path} #{abcs[RAILS_ENV]["database"]}` | |
+ `pg_dump -i -s -x -O -f db/structure.sql #{search_path} #{abcs[RAILS_ENV]["database"]}` | |
raise "Error dumping database" if $?.exitstatus == 1 | |
when "sqlite", "sqlite3" | |
dbfile = abcs[RAILS_ENV]["database"] || abcs[RAILS_ENV]["dbfile"] | |
- `#{abcs[RAILS_ENV]["adapter"]} #{dbfile} .schema > db/#{RAILS_ENV}_structure.sql` | |
+ `#{abcs[RAILS_ENV]["adapter"]} #{dbfile} .schema > db/structure.sql` | |
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\\structure.sql /q /A /r` | |
`scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /F db\ /q /A /r` | |
when "firebird" | |
set_firebird_env(abcs[RAILS_ENV]) | |
db_string = firebird_db_string(abcs[RAILS_ENV]) | |
- sh "isql -a #{db_string} > #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql" | |
+ sh "isql -a #{db_string} > #{RAILS_ROOT}/db/structure.sql" | |
else | |
raise "Task not supported by '#{abcs["test"]["adapter"]}'" | |
end | |
if ActiveRecord::Base.connection.supports_migrations? | |
- File.open("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql", "a") { |f| f << ActiveRecord::Base.connection.dump_schema_information } | |
+ File.open("#{RAILS_ROOT}/db/structure.sql", "a") { |f| f << ActiveRecord::Base.connection.dump_schema_information } | |
end | |
end | |
- end | |
- | |
- namespace :test do | |
- desc "Recreate the test database from the current schema.rb" | |
- task :load => '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 database from the current environment's database schema" | |
- task :clone => %w(db:schema:dump db:test:load) | |
- desc "Recreate the test databases from the development structure" | |
- task :clone_structure => [ "db:structure:dump", "db:test:purge" ] do | |
+ desc "Load a structure.sql file into the database" | |
+ task :load => :environment do | |
abcs = ActiveRecord::Base.configurations | |
- case abcs["test"]["adapter"] | |
+ case abcs[RAILS_ENV]["adapter"] | |
when /^mysql/ | |
- ActiveRecord::Base.establish_connection(:test) | |
+ ActiveRecord::Base.establish_connection(abcs[RAILS_ENV]) | |
ActiveRecord::Base.connection.execute('SET foreign_key_checks = 0') | |
- IO.readlines("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql").join.split("\n\n").each do |table| | |
+ IO.readlines("#{RAILS_ROOT}/db/structure.sql").join.split("\n\n").each do |table| | |
ActiveRecord::Base.connection.execute(table) | |
end | |
when "postgresql" | |
- ENV['PGHOST'] = abcs["test"]["host"] if abcs["test"]["host"] | |
- ENV['PGPORT'] = abcs["test"]["port"].to_s if abcs["test"]["port"] | |
- ENV['PGPASSWORD'] = abcs["test"]["password"].to_s if abcs["test"]["password"] | |
- `psql -U "#{abcs["test"]["username"]}" -f #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql #{abcs["test"]["database"]}` | |
+ ENV['PGHOST'] = abcs[RAILS_ENV]["host"] if abcs[RAILS_ENV]["host"] | |
+ ENV['PGPORT'] = abcs[RAILS_ENV]["port"].to_s if abcs[RAILS_ENV]["port"] | |
+ ENV['PGPASSWORD'] = abcs[RAILS_ENV]["password"].to_s if abcs[RAILS_ENV]["password"] | |
+ ENV['PGUSER'] = abcs[RAILS_ENV]["username"] if abcs[RAILS_ENV]["username"] | |
+ | |
+ `psql -f #{RAILS_ROOT}/db/structure.sql #{abcs[RAILS_ENV]["database"]}` | |
when "sqlite", "sqlite3" | |
- dbfile = abcs["test"]["database"] || abcs["test"]["dbfile"] | |
- `#{abcs["test"]["adapter"]} #{dbfile} < #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql` | |
+ dbfile = abcs[RAILS_ENV]["database"] || abcs[RAILS_ENV]["dbfile"] | |
+ `#{abcs[RAILS_ENV]["adapter"]} #{dbfile} < #{RAILS_ROOT}/db/structure.sql` | |
when "sqlserver" | |
- `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql` | |
+ `osql -E -S #{abcs[RAILS_ENV]["host"]} -d #{abcs[RAILS_ENV]["database"]} -i db\\structure.sql` | |
when "oci", "oracle" | |
- ActiveRecord::Base.establish_connection(:test) | |
- IO.readlines("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql").join.split(";\n\n").each do |ddl| | |
+ ActiveRecord::Base.establish_connection(abcs[RAILS_ENV]) | |
+ IO.readlines("#{RAILS_ROOT}/db/structure.sql").join.split(";\n\n").each do |ddl| | |
ActiveRecord::Base.connection.execute(ddl) | |
end | |
when "firebird" | |
- set_firebird_env(abcs["test"]) | |
- db_string = firebird_db_string(abcs["test"]) | |
- sh "isql -i #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql #{db_string}" | |
+ set_firebird_env(abcs[RAILS_ENV]) | |
+ db_string = firebird_db_string(abcs[RAILS_ENV]) | |
+ sh "isql -i #{RAILS_ROOT}/db/structure.sql #{db_string}" | |
else | |
- raise "Task not supported by '#{abcs["test"]["adapter"]}'" | |
+ raise "Task not supported by '#{abcs[RAILS_ENV]["adapter"]}'" | |
end | |
end | |
+ end | |
+ | |
+ namespace :test do | |
+ desc "Recreate the test database from the current schema.rb or structure.sql" | |
+ task :load => 'db:test:purge' do | |
+ ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test']) | |
+ ActiveRecord::Schema.verbose = false | |
+ Rake::Task["db:schema:load"].invoke if ActiveRecord::Base.schema_format == :ruby | |
+ Rake::Task["db:structure:load"].invoke if ActiveRecord::Base.schema_format == :sql | |
+ 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 the structure.sql file" | |
+ task :clone_structure => [ "db:structure:dump", "db:test:load" ] | |
desc "Empty the test database" | |
task :purge => :environment do | |
@@ -367,7 +386,7 @@ | |
when "sqlserver" | |
dropfkscript = "#{abcs["test"]["host"]}.#{abcs["test"]["database"]}.DP1".gsub(/\\/,'-') | |
`osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{dropfkscript}` | |
- `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql` | |
+ `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\structure.sql` | |
when "oci", "oracle" | |
ActiveRecord::Base.establish_connection(:test) | |
ActiveRecord::Base.connection.structure_drop.split(";\n\n").each do |ddl| |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment