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

Add support for fetching non-public schemas. #96

Merged
merged 2 commits into from
Jan 29, 2024

Conversation

bplunkett-stripe
Copy link
Collaborator

@bplunkett-stripe bplunkett-stripe commented Jan 29, 2024

Description

This only adds support for fetching non-public schemas. This does actually allow generating migration plans for non-public schemas because we will need plumb several into the sql generation code to account for schemas.

I opted to do the filtering in-memory because it is way more flexible to do the filtering in-memory rather than in the queries. We can easily support things like regex and complex nested operations in the future (unions of intersections, etc). I don't expect the filters to significantly reduce the number of schema objects being fetched, so the performance impact of doing it in-memory is minimal.

Motivation

#94

Testing

Tested via unit tests


return concurrent.GetAll(ctx, tableFutures...)
}
tables = filterSliceByName(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is way more flexible to do this filtering in-memory rather than in the query. We can easily support things like regex and complex nested operations in the future (unions of intersections, etc).

@@ -25,8 +29,8 @@ LEFT JOIN
pg_catalog.pg_namespace AS parent_namespace
ON parent_c.relnamespace = parent_namespace.oid
WHERE
c.relnamespace
= (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = 'public')
table_namespace.nspname NOT IN ('pg_catalog', 'information_schema')
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same filter Postgres uses in its pg_stat_user_tables view to filter down from pg_stat_all_tables.

@bplunkett-stripe bplunkett-stripe force-pushed the bplunkett/fetch-non-public-schemas branch from 970ecbc to 9863ee2 Compare January 29, 2024 05:41
Copy link

@ericw-stripe ericw-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@bplunkett-stripe bplunkett-stripe merged commit 4be624d into main Jan 29, 2024
6 checks passed
@bplunkett-stripe bplunkett-stripe deleted the bplunkett/fetch-non-public-schemas branch January 29, 2024 18:28
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