-
Notifications
You must be signed in to change notification settings - Fork 364
fix: add schema qualification hints for extension type errors #4513
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
fix: add schema qualification hints for extension type errors #4513
Conversation
|
Thanks for checking. Our current recommendation is to always use schema qualified references in your migration file. For eg. CREATE TABLE test (path extensions.ltree NOT NULL);This avoids ambiguity in default search path resolution which can be configured per session, per role, or per cluster. The default search path for Supabase postgres role is currently set to |
@sweatybridge Thanks for the elaboration! I get that relying on a fixed search_path isn’t future-proof. |
Do you plan to do this by inspecting the error object returned from pgx? If so, that sounds good to me. Thanks for your help. |
Yep, I’ll inspect the pgx error and add the clearer message + schema qualification hint. On it |
b68f5bb to
1b972d2
Compare
Pull Request Test Coverage Report for Build 21779030687Details
💛 - Coveralls |
1b972d2 to
711463f
Compare
|
@sweatybridge whenever you have a moment, a quick review would be appreciated. 💚 |
sweatybridge
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few nitpicks
|
@sweatybridge All requested changes have been applied. Ready for rereview. |
8def4f9 to
3395b48
Compare
|
@sweatybridge heyy! |
|
Can we add some unit tests for the new code please? |
Inspect pgx errors for SQLSTATE 42704 (undefined_object) and provide helpful hints when extension types are not found. The error message now: - Detects 'type does not exist' errors - Extracts the type name from the error message - Suggests using schema-qualified references (e.g., extensions.ltree) - Provides a concrete example in the error output This addresses the issue where migrations work locally but fail remotely with opaque 'type does not exist' errors, making it clear to users that they should use schema-qualified type references instead of relying on search_path settings.
b2873f8 to
c01e0da
Compare
Added unit tests for extractTypeName function |
Summary
Improve CLI migration errors for undefined PostgreSQL extension types by adding a context aware hint for unqualified type references.
Problem
Migrations can fail with:
This error does not indicate whether the type is missing due to schema visibility,
extension installation, or configuration differences.
Solution
Inspect pgconn.PgError during migration execution and conditionally provide a schema-qualification hint only when the referenced type is not already schema-qualified.
Related