Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't load columns from tables in other schemas #15

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

pjungwir
Copy link

@pjungwir pjungwir commented Jun 6, 2016

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 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.

@amarshall
Copy link
Contributor

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 [email protected]
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:

#15
Commit Summary

  • Don't load columns from tables in other schemas

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#15, or mute the thread
https://github.com/notifications/unsubscribe/AAJWV7pLUcy7tbZzpTiA1lpGOo-gAsrWks5qJLBwgaJpZM4IvbB4
.

@pjungwir
Copy link
Author

pjungwir commented Jun 7, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants