Skip to content

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

Open
pjungwir wants to merge 3 commits intoCasecommons:masterfrom
pjungwir:schemas
Open

Don't load columns from tables in other schemas#15
pjungwir wants to merge 3 commits intoCasecommons:masterfrom
pjungwir:schemas

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

#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