prisma1
prisma1 copied to clipboard
Error relation "default$default.user" does not exist. Existing pgsql db
Hi, I try to run prisma on my existing postgres db, but after few hours I'm in same buggy spot. I have public schema
in db but prisma try to resolve queries on default$default
.
My docker-compose.yml
version: "3.6"
services:
offhub_pgsql:
image: postgres:9.6.6-alpine
volumes:
- ./postgres_data:/var/lib/postgresql/data/
environment:
POSTGRES_USER: offhub
POSTGRES_PASSWORD: offhub
POSTGRES_DB: offhub
ports:
- 5432:5432
offhub_backend:
build: .
command: npm run dev
volumes:
- ./:/app
- /app/node_modules
env_file:
- .env
depends_on:
- offhub_pgsql
ports:
- 9229:9229
offhub_nginx:
build:
dockerfile: Dockerfile
context: nginx/
ports:
- 3030:80
depends_on:
- offhub_backend
prisma:
image: prismagraphql/prisma:1.29.2
restart: always
ports:
- "4466:4466"
environment:
PRISMA_CONFIG: |
port: 4466
# uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
managementApiSecret: my-secret
databases:
default:
connector: postgres
host: host.docker.internal
database: offhub
user: offhub
password: offhub
rawAccess: true
port: '5432'
migrations: false
volumes:
postgres:
My prisma.yml
Btw I think there is another issue. I can't do prisma deploy
if it's not on localhost http://localhost:4466
endpoint: http://host.docker.internal:4466
datamodel: datamodel.prisma
generate:
- generator: typescript-client
output: ./generated/prisma-client/
I've also tried just with simple model from db:
type User @pgTable(name: "user") {
id: UUID! @unique
name: String
}
and behaviour is still same.
I've tried quering by playground and with express by adding:
import { prisma } from "../../prisma/generated/prisma-client"
// A `main` function so that we can use async/await
async function main() {
// Create a new user called `Alice`
const newUser = await prisma.createUser({ name: "Alice" })
console.log(`Created new user: ${newUser.name} (ID: ${newUser.id})`)
// Read all users from the database and print them to the console
const allUsers = await prisma.users()
console.log(allUsers)
}
main().catch(e => console.error(e))
Postgres logs:
Prisma logs:
Express logs:
When I've tried this config on empty db with migrations:true
prisma created default$default schema and everything seem to work fine but it isn't behaviour that I'm looking for.
Versions (please complete the following information):
- Connector:
Postgres
- Prisma Server:
1.29.2
-
prisma
CLI:prisma/1.29.1 (darwin-x64) node-v10.15.1
- OS:
OS X High Sierra
- other dependencies:
prisma-client
thx for help 😄
@SawasReaper : Thanks for raising this issue with a reproduction, I was able to reproduce it. This is happening because of this bug in Prisma CLI: https://github.com/prisma/prisma/issues/4282 which makes Prisma server go to an incorrect code path.
A fix will be required in both CLI and server side. However, a workaround is to add the schema
name to docker-compose.yml
file manually and then run docker-compose-up -d
followed by prisma deploy
.
Please let me know if this workaround works for you.
P.S. here is my reproduction for this issue: https://github.com/divyenduz/prisma-4278
@divyenduz thanks for quick answer. Adding schema: public
worked for me perfectly. To be honest I've tried it before but I've had some issue with prisma deploy
. Now works perfectly.


Should I create another issue for bug I mentioned before? It's related with prisma deploy
on endpoint: http://host.docker.internal:4466

When I go with endpoint: http://localhost:4466
everything is fine with prisma deploy
but dockerized express rise issue on prisma generated
endpoint and I need to replace it manually with endpoint: http://host.docker.internal:4466
in index.ts

Thanks for letting us know, the issue regarding authentication is actively being discussed here: https://github.com/prisma/prisma/issues/4215
I can imaging why this is failing, we need to mark host.docker.internal
explicitly as localhost.
Hmm, I think I found another one. It's related with schema: public
. When I added it to my docker-compose.yml and went with prisma deploy
it crashes on my real pgsql database and nth wasn't added to project/migration tables in managment schema.

But when I comment schema: public
and run prisma deploy
it's 👌 and my model is added to migration table in managment schema.


Then I uncommented my schema: public
and restarted docker container and it's fine.

Full log from debug:

If you need some more info please tell me. I'm happy to help.
@SawasReaper It should be schema:pubic
right? as schema
is the key that Prisma reads to choose the schema name which is public
.
Yes, of course. I've done it like this schema: public
.
@divyenduz Should I open another issue for that?
@SawasReaper : Thank you, please create another issue with a minimal reproduction 🙏 That would help us tackle them separately.
I'm using schema:public and it does not seem to have any effect, I'm still getting:
The provided schema "default$default" does not exist. The following are available: public, management