Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/postgres/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,13 @@ func extensionsToInstall(extensions, alreadyAvailableExtensions Extensions) (Ext
// installExtensions actually enable extensions on the database
func installExtensions(ctx context.Context, conn *sql.DB, adminCredentials, serviceCredentials Credentials, extensionsToInstall []Extension) error {
for _, e := range extensionsToInstall {
// Extensions are installed into the schema of the service, ie. the one
// named after the service user, and never the schema of another service on
// the same database. For shared databases the database name is the name of
// another service's schema.
_, err := conn.ExecContext(
ctx,
fmt.Sprintf("CREATE EXTENSION IF NOT EXISTS %s WITH SCHEMA %s", e.Name, serviceCredentials.Name),
fmt.Sprintf("CREATE EXTENSION IF NOT EXISTS %s WITH SCHEMA %s", e.Name, serviceCredentials.User),
)
if err != nil {
return fmt.Errorf("failed to install: user: %s, db: %s, extension %s: %w", adminCredentials.User, serviceCredentials.Name, e.Name, err)
Expand Down
Loading