medusajs / medusa

Building blocks for digital commerce
https://medusajs.com
MIT License
24.45k stars 2.4k forks source link

Migration fails when using schema other than public and restricted postgres role #6747

Open vethan opened 5 months ago

vethan commented 5 months ago

Bug report

Describe the bug

If you create a user in your database with permissions over a schema that is not public, and no permission on the postgres public schema, the initial migrations will fail due to: query failed: DROP INDEX IF EXISTS "public"."UniqPaymentSessionCartIdProviderId

System information

Medusa version (including plugins): 1.20.2 Node.js version: N/A Database: postgres Operating system: Windows Browser (if relevant): N/A

Steps to reproduce the behavior

  1. Create a postgres database with user medusa_test, and schema medusa
  2. Grant all permissions on medusa schema to medusa_test
  3. In medusaconfig.js setup database_url to connect to postgres with medusa_test user
  4. In medusaconfig.js set database_schema to "medusa"
  5. run npx medusa migrations run
  6. See error

Expected behavior

Migrations to complete successfully

MuhammadRafay151 commented 1 month ago

Has the issue been resolved?