rails/rails — comment on commit 3fee2378edd45188e41a7d14d4ca0a88280b541e
File:  line 0
By nicb:

The database I'm working with has already been in production for several years. They had an 'old implementation' of the database in the `public` schema, and they did a new implementation using a different schema name. That sounds silly perhaps, but 'they' is somebody I don't know so I can't even ask why they did it this way. Since I cannot change the structure of the production database, I have two options:
1. use a different schema (using only `public`) for the testing suite
2. try to fix this issue
I could easily do (1) but I don't think it is the correct way to go. If the ruby pg adapter supports schemas and the rails implementation supports schemas (which it does, since you can define them in configuration), then we should be able to run tests on the database configured for tests as it is for production. Also because otherwise these tests are missing one important point which could crop up in production.

I am starting to think how to fix it. The super-easiest fix of them all is to set an environment variable like:

```ruby
sspath = ENV['PG_SCHEMA_SEARCH_PATH'] || 'public'
....
ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => sspath))
```
I don't know if that is enough to actually do the job properly. I am proposing it here to you before checking it to bar probable naiveties on my side.