Skip to content

dp-152/prisma-postgres-schema-inconsistency

Repository files navigation

prisma-postgres-schema-inconsistency

A reproducible example of a schema inconsistency issue when using Prisma with PostgreSQL.

Description

When using Prisma with PostgreSQL, if the connection string specifies a schema other than 'public', the generated queries will still reference the 'public' schema unless the schema option is explicitly set in the adapter configuration. This leads to query failures unless all raw queries are also prefixed with the specified schema, as the search path does not include the specified schema by default. This issue does not occur when using prisma-client-js without an adapter.

Steps to Reproduce

  1. Clone the repository.
  2. Install dependencies using pnpm install.
  3. Run the included docker-compose.yml to initialize a database instance.
  4. Run pnpm prisma migrate deploy to apply the migrations.
  5. Run pnpm prisma generate to generate the Prisma client.
  6. Run both scenarios with pnpm start:scenario-1 and pnpm start:scenario-2 to reproduce the schema inconsistency issue.

Expected Behavior

The queries should respect the schema defined in the connection string.

Actual Behavior

Queries generated by the ORM will fail due to all tables being prefixed with the 'public.' schema, despite the connection string specifying a different schema, unless the schema option is explicitly set in the adapter configuration. Even with the schema option set, any raw queries ($executeRaw, $executeRawUnsafe) that are not prefixed with the schema will fail, due to the search path not including the specified schema.

Environment

  • Prisma version: 6.16.2
  • Node.js version: 22.18

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors