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

[PG] Allow migration without CREATE SCHEMA permission #4025

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

barklund
Copy link

@barklund barklund commented Jan 28, 2025

Description

Currently the migration uses CREATE SCHEMA IF NOT EXISTS, however that requires permission to create a schema even if there's already one. This change allows the migrations to be run by a user without the CREATE SCHEMA permission as long as the schema has already been created in advance.

FEATURES

  • Manually check for schema existence before creating one, rather than rely on CREATE SCHEMA IF NOT EXISTS.

Test Plan

This includes a new test, that creates a restricted user without the CREATE permission on the database level, and then tries to migrate using that restricted user. It then cleans up after itself.

This did require a minor rewrite of the setup to allow reusing some functionality to create a new DB connection for the restricted user.

Subscribers

Issue

Fixes #2161
Fixes #3353

Currently the migration uses `CREATE SCHEMA IF NOT EXISTS`, however that requires permission to create a schema even if there's already one. This change allows the migrations to be run by a user without the `CREATE SCHEMA` permission as long as the schema has already been created in advance.

This includes a test, that failed before, but works now after the small change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant