30 juillet 2009

schema_search_path in Postgres adapter

I've found that problem when using the Postgres adapter (and Rails 2.1.1) with multiple schemas (because I am not using the default Postgres user to connect to the database).

The error you get is:

PGError: ERROR: relation "schema_migrations" already exists


The root cause is that the Postgres adapter returns no table names, because the schemas it looks into are like this: 'schema1', ' public' (the extra space before public is the problem)

I've found one post that accurately describes the problem

The easy fix is to add a schema_search_path definition in config/database.yml like so:

schema_search_path: public

Aucun commentaire:

Enregistrer un commentaire