Issue #29 invalid

rake db:test:prepares fails if schema_search_path is set and different from public

jdi
created an issue

Environment:

ruby 1.8.7, rails 2.3.5, postgresql 8.4, pg 0.9.0, WinXP SP3


I have a login user railsuser which has all rights except the superuser. My database.yml file looks like this:

{{{ development: adapter: postgresql encoding: UTF8 database: cbdev schema_search_path: cbdev pool: 5 username: railsuser password: railsuser

test: adapter: postgresql encoding: UTF8 database: cbtest schema_search_path: cbtest pool: 5 username: railsuser password: railsuser }}}

All work in Dev works fine. All tables etc are created in schema cbdev in database cbdev. If I run rake db:test:migrate I get an error:

{{{
D:\ProgrammerProjects\Rails Projects\cb30>rake db:test:prepare
(in D:/ProgrammerProjects/Rails Projects/cb30)
rake aborted!
PGError: ERROR: schema "cbtest" does not exist
SET search_path TO cbtest

(See full trace by running task with --trace) }}}

OK - schema created in DB cbtest and railsuser is the owner, but running the command again, I get the same error message again and the manually created schema cbtest is deleted in database cbtest. Reproduced with different names for the schema in the test database. Interesting is, if I comment out the schema_search_path for the "test:" area it works fine in the public schema. However it drops the tables in public first (and I feel it drops the whole schema public first) - but then all tables in public are availbale from the cbdev environment.

Full trace:

{{{ (in D:/ProgrammerProjects/Rails Projects/cb30) Invoke db:test:prepare (first_time) Invoke db:abort_if_pending_migrations (first_time) Invoke environment (first_time) Execute environment Execute db:abort_if_pending_migrations Execute db:test:prepare Invoke db:test:load (first_time) Invoke db:test:purge (first_time) Invoke environment Execute db:test:purge Execute db:test:load Invoke db:schema:load (first_time) Invoke environment Execute db:schema:load

rake aborted!
PGError: ERROR: schema "cbtest" does not exist
SET search_path TO cbtest D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract_adapter.rb:219:in log' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/postgresql_adapter.rb:550:inexecute' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/postgresql_adapter.rb:730:in schema_search_path=' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/postgresql_adapter.rb:1013:inconfigure_connection' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/postgresql_adapter.rb:999:in connect' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/postgresql_adapter.rb:217:ininitialize' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in new' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/postgresql_adapter.rb:37:inpostgresql_connection' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in send' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:innew_connection' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:245:in checkout_new_connection' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:188:incheckout' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in loop' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:incheckout' D:/Portable/ruby/ruby187/lib/ruby/1.8/monitor.rb:242:in synchronize' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:183:incheckout' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:98:in connection' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:326:inretrieve_connection' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_specification.rb:123:in retrieve_connection' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_specification.rb:115:inconnection' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:342:in connection' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:352:inmethod_missing' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:328:in say_with_time' D:/Portable/ruby/ruby187/lib/ruby/1.8/benchmark.rb:293:inmeasure' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:328:in say_with_time' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:348:inmethod_missing' D:/ProgrammerProjects/Rails Projects/cb30/db/schema.rb:14 D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/schema.rb:43:in instance_eval' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/schema.rb:43:indefine' D:/ProgrammerProjects/Rails Projects/cb30/db/schema.rb:12 D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:145:in load_without_new_constant_marking' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:145:inload' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in new_constants_in' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:145:inload' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/tasks/databases.rake:269 D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in call' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:inexecute' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in each' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:inexecute' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in invoke_with_call_chain' D:/Portable/ruby/ruby187/lib/ruby/1.8/monitor.rb:242:insynchronize' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in invoke_with_call_chain' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:ininvoke' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/tasks/databases.rake:317 D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in call' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:inexecute' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in each' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:inexecute' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in invoke_with_call_chain' D:/Portable/ruby/ruby187/lib/ruby/1.8/monitor.rb:242:insynchronize' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in invoke_with_call_chain' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:ininvoke' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/tasks/databases.rake:391 D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in call' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:inexecute' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in each' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:inexecute' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in invoke_with_call_chain' D:/Portable/ruby/ruby187/lib/ruby/1.8/monitor.rb:242:insynchronize' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in invoke_with_call_chain' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:ininvoke' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in invoke_task' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:intop_level' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in each' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:intop_level' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in standard_exception_handling' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:intop_level' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in run' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in run' D:/Portable/ruby/ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31 D:/Portable/ruby/ruby187/bin/rake:19:inload' D:/Portable/ruby/ruby187/bin/rake:19 }}}

Comments (2)

  1. Michael Granger repo owner

    This appears to be a problem with the ActiveRecord 'postgres' adapter or a Rails rake task, if I'm understanding it correctly. Either way, it's not the 'pg' code that's at fault. I'd suggest filing this as a bug against either Rails or ActiveRecord.

  2. Log in to comment