Open pjungwir opened 8 years ago
Is it possible to specify the schema in the database.yml
? If so this
should use the value specified in the connection config instead of a
hard-coded default.
On Mon, Jun 6, 2016 at 19:42 Paul A Jungwirth notifications@github.com wrote:
By default Rails puts its tables in the public schema. But sometimes other schemas are used, for instance for history https://www.youtube.com/watch?v=TRgni5q0YM8, reporting, multiple tenants https://github.com/influitive/apartment, etc. It is common for these other schemas to have tables with the same name as the table from the public schema (see links above). Currently when pg_audit_log queries information_schema.columns, it gets all columns from all schemas, which causes errors when it tries to record the changes that happened. This change makes pg_audit_log look only in the public schema, so it doesn't
break if other schemas are used.
You can view, comment on, or merge this pull request online at:
https://github.com/Casecommons/pg_audit_log/pull/15 Commit Summary
- Don't load columns from tables in other schemas
File Changes
- M lib/pg_audit_log/function.rb https://github.com/Casecommons/pg_audit_log/pull/15/files#diff-0 (2)
Patch Links:
- https://github.com/Casecommons/pg_audit_log/pull/15.patch
- https://github.com/Casecommons/pg_audit_log/pull/15.diff
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Casecommons/pg_audit_log/pull/15, or mute the thread https://github.com/notifications/unsubscribe/AAJWV7pLUcy7tbZzpTiA1lpGOo-gAsrWks5qJLBwgaJpZM4IvbB4 .
The best you can do from database.yml
is schema_search_path
, which seems not quite right. I changed the PR so that the old behavior is unchanged by default, but you can restrict pg_audit_log to just one schema by passing a param to the install
function or setting an envvar when you run the rake task.
By default Rails puts its tables in the
public
schema. But sometimes other schemas are used, for instance for history, reporting, multiple tenants, etc. It is common for these other schemas to have tables with the same name as the table from thepublic
schema (see links above). Currently when pg_audit_log queriesinformation_schema.columns
, it gets all columns from all schemas, which causes errors when it tries to record the changes that happened. This change makes pg_audit_log look only in thepublic
schema, so it doesn't break if other schemas are used.