Install extensions in the service's own schema - #386
Merged
Conversation
Extensions were installed with `WITH SCHEMA <database name>`. For shared databases the database name is the name of another service's schema, so extensions ended up in the wrong schema. Use the service user name instead, which is the schema owned by the service itself.
mahlunar
marked this pull request as ready for review
August 4, 2026 08:35
tmablunar
approved these changes
Aug 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
installExtensionscreated extensions withWITH SCHEMA <serviceCredentials.Name>, i.e. the database name. For shared databases the database name is the name of another service's schema, so extensions could be installed into a schema belonging to a different service. In almost all cases, this changes nothing as normally only one service uses a single database.Change
Use
serviceCredentials.Userinstead — the schema named after the service user, which the service actually owns.Notes
Note
Medium Risk
Changes where new extensions are created on shared databases; existing mis-placed extensions are not migrated, so behaviour only affects new installs.
Overview
installExtensionsnow runsCREATE EXTENSION ... WITH SCHEMAusingserviceCredentials.Userinstead ofserviceCredentials.Name, so extensions land in the schema owned by the service user.On shared databases, the database name can match another service’s schema, which previously caused extensions to be created in the wrong schema. Dedicated databases where name and user match are unchanged.
This does not relocate extensions already created in the wrong schema.
Reviewed by Cursor Bugbot for commit 85ee40a. Configure here.