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

Running migrations requires schema permissions on postgres #3106

Closed
mpauly-exnaton opened this issue May 12, 2022 · 2 comments
Closed

Running migrations requires schema permissions on postgres #3106

mpauly-exnaton opened this issue May 12, 2022 · 2 comments

Comments

@mpauly-exnaton
Copy link

mpauly-exnaton commented May 12, 2022

This commit runs a create schema if not exists on running migrations on postgres if I am not mistaken. The corresponding query will fail if the assigned user does not have appropriate permissions, even if the schema already exists. This is not ideal, as it requires giving the MikroORM users additional permissions.

Error on running the migrations:

error: create schema if not exists "public" - permission denied for database onboarding
    at Parser.parseErrorMessage (/Users/mpauly/something/node_modules/pg-protocol/src/parser.ts:369:69)
    at Parser.handlePacket (/Users/mpauly/something/node_modules/pg-protocol/src/parser.ts:188:21)
    at Parser.parse (/Users/mpauly/something/node_modules/pg-protocol/src/parser.ts:103:30)
    at Socket.<anonymous> (/Users/mpauly/something/node_modules/pg-protocol/src/index.ts:7:48)

To Reproduce
Steps to reproduce the behavior:

  1. Setup a database and create a user that does not have permissions to edit schemas
  2. Create an initial migration with npm run mikro-orm -- migration:create
  3. Apply the migration with npm run mikro-orm -- migration:up

Expected behavior
The migration is applied as a schema already exists.

Versions
As expected, for me the bug only occurs with version 5.1.3.

Dependency Version
node 17.6.0
typescript 4.6.2
mikro-orm 5.1.3
@mikro-orm/postgresql 5.1.3
@B4nan
Copy link
Member

B4nan commented May 17, 2022

How does your ORM config look like? This query should be invoked only if you specify the schema name explicitly in the migrations table name. Which you should not if its public schema, as that is the default.

@B4nan B4nan closed this as completed in d6af811 May 18, 2022
@mpauly-exnaton
Copy link
Author

As far as I am aware, the ORM config did not contain an explicit schema in our case, but I might be mistaken.

Thanks for fixing this, and thanks a lot for running mikro-orm!

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

No branches or pull requests

2 participants