Postgres Schema default$default

prisma

#1

How do I specify which schema Prisma should generate tables under? I can see it defaults to default$default right now


#2

You do that using the endpoint property in prisma.yml.

http://localhost:4466 equals http://localhost:4466/default/default.

So you can enter

endpoint: http://localhost:4466/servicename/stagename

Then Prisma will use the servicename$stagename schema in your database.

(All of this assumes your Prisma server runs at http://localhost:4466).


#3

Can I specify Prisma to use the “public” schema in Postgres? I’m connecting to an existing Postgres database that doesn’t put tables under a schema


#4

The configuration for the Postgres connector provides a “database” key, is that the one you refer you?

You can see it here: https://www.prisma.io/docs/reference/prisma-servers-and-dbs/database-connectors/postgres-neix6nesie


#5

Ah sorry I didn’t see that you are connecting to an existing database.

Running prisma introspect should currently connect to the public schema already, is that not the case for you?

See https://github.com/prismagraphql/prisma/issues/2256 for more context.


#6

Yeah when I ran prisma introspect it generated the schema correctly but when I went to deploy it, it would still look at default$default

So for example, the existing database looks like this…

prisma (this is the postgres database)
  - user (existing table created in the database)

when I try to deploy, it’ll create the default$default schema:

prisma
  - user
  default$default

and throw an error saying it can’t find default$default.user

I could have done something wrong, so I’ll try it again. I understand it’s an experimental feature :slight_smile:


#7

Oh wait, my bad… I just needed to specify schema: public in my docker-compose. Working now :slight_smile: oops!


#8

Awesome, we should definitely add that information to the docs! I created an issue for this here: https://github.com/prismagraphql/prisma/issues/2631 :slight_smile:


#9

Hm, so I’m able to query for users and it will correctly return all the users in the database but when i query for an individual user, it returns null…


#10

I have the same problem, but even after specifying schema: public in docker-compose.yml, prisma will still use default$default schema.


#11

This seems related: https://github.com/prismagraphql/prisma/issues/2846.