From c38a33d9a16928ff8a38bbf4fcbb5ef8197baef3 Mon Sep 17 00:00:00 2001 From: Drew Chandler Date: Sun, 9 Jan 2011 14:45:54 -0800 Subject: [PATCH] use --single-transaction in db:test:clone_structure for postgresql When ActiveRecord::Base.schema_format is set to :sql and the user has turned off autocommit in their .psqlrc file, the results of db:test:clone_structure will not be committed. Adding in the --single-transaction flag to the psql command will wrap the sql in a BEGIN\COMMIT and will make sure that the commands get committed. --- .../lib/active_record/railties/databases.rake | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake index 9924755..1e39ba1 100644 --- a/activerecord/lib/active_record/railties/databases.rake +++ b/activerecord/lib/active_record/railties/databases.rake @@ -409,7 +409,7 @@ db_namespace = namespace :db do 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"]} #{abcs["test"]["template"]}` + `psql -U "#{abcs["test"]["username"]}" --single-transaction -f #{Rails.root}/db/#{Rails.env}_structure.sql #{abcs["test"]["database"]} #{abcs["test"]["template"]}` when "sqlite", "sqlite3" dbfile = abcs["test"]["database"] || abcs["test"]["dbfile"] `#{abcs["test"]["adapter"]} #{dbfile} < #{Rails.root}/db/#{Rails.env}_structure.sql` -- 1.7.3.5