Describe the bug
A clear and concise description of what the bug is.
When schema: public option is provided in docker-compose.yml, Prisma successfully executes queries on tables in public schema of existing PostgreSQL database. But during mutations, Prisma looks for the table in default$default schema and then PostgreSQL throws the following error since the table exists in public schema and not default$default schema.
prisma_1 | org.postgresql.util.PSQLException: ERROR: relation "default$default.manager_keyword" does not exist
To Reproduce
Steps to reproduce the behavior:
1) Create files
prisma init
Selecting existing PostgreSQL database during prisma init creates prisma.yml, datamodel.graphql and docker-compose.yml.
prisma.yml:
endpoint: http://localhost:4466
datamodel: datamodel.graphql
datamodel.graphql:
type Manager_keyword @pgTable(name: "manager_keyword") {
id: Int! @unique
geo: String
keyword: String
}
docker-compose.yml:
version: '3'
services:
prisma:
image: prismagraphql/prisma:1.14
restart: always
ports:
- "4466:4466"
environment:
PRISMA_CONFIG: |
port: 4466
databases:
default:
connector: postgres
host: ***.rds.amazonaws.com
port: '5432'
database: ***
schema: public
user: ***
password: ***
migrations: false
2) Deploy
docker-compose up (-d option omitted to view logs)
In another terminal,
prisma deploy
3) Query
Executing this query in graphql playground (localhost:4466)
{
manager_keywords {
id
geo
keyword
}
}
gives this result:
{
"data": {
"manager_keywords": [
{
"id": 1,
"geo": "DE",
"keyword": "kw1"
},
{
"id": 2,
"geo": "UK",
"keyword": "kw2"
}
]
}
}
which is expected and matches the result from psql:
SELECT * FROM manager_keyword;
id | keyword | geo
----+---------+-----
1 | kw1 | DE
2 | kw2 | UK
(2 rows)
This shows that prisma is able to read from the public schema of PostgreSQL.
4) Error during mutations
Executing the create mutation
mutation {
createManager_keyword(data: { geo: "FR", keyword: "kw3" }) {
id
geo
keyword
}
}
results in this error in graphql playground:
{
"data": null,
"errors": [
{
"message": "Whoops. Looks like an internal server error. Search your server logs for request ID: local:api:cjkb3vjy3000b0856unkcajlv",
"path": [
"createManager_keyword"
],
"locations": [
{
"line": 2,
"column": 3
}
],
"requestId": "local:api:cjkb3vjy3000b0856unkcajlv"
}
]
}
and a corresponding error from PostgreSQL in docker-compose up:
prisma_1 | {"key":"error/unhandled","requestId":"local:api:cjkb3vjy3000b0856unkcajlv","clientId":"default$default","payload":{"exception":"org.postgresql.util.PSQLException: ERROR: relation \"default$default.manager_keyword\" does not exist\n Position: 13","query":"mutation {\n createManager_keyword(data: {geo: \"UK\", keyword: \"kw3\"}) {\n id\n geo\n keyword\n }\n}\n","variables":"{}","code":"0","stack_trace":"org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2433)\\n org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2178)\\n org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:306)\\n org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)\\n org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)\\n org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:155)\\n org.postgresql.jdbc.PgPreparedStatement.execute(PgPreparedStatement.java:144)\\n com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44)\\n com.zaxxer.hikari.pool.HikariProxyPreparedStatement.execute(HikariProxyPreparedStatement.java)\\n com.prisma.api.connector.jdbc.database.BuilderBase.$anonfun$insertReturningGeneratedKeysToDBIO$1(BuilderBase.scala:64)\\n com.prisma.api.connector.jdbc.database.BuilderBase.$anonfun$jooqToDBIO$1(BuilderBase.scala:87)\\n slick.jdbc.SimpleJdbcAction.run(StreamingInvokerAction.scala:70)\\n slick.jdbc.SimpleJdbcAction.run(StreamingInvokerAction.scala:69)\\n slick.basic.BasicBackend$DatabaseDef$$anon$2.liftedTree1$1(BasicBackend.scala:275)\\n slick.basic.BasicBackend$DatabaseDef$$anon$2.run(BasicBackend.scala:275)\\n java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\\n java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\\n java.lang.Thread.run(Thread.java:748)","message":"ERROR: relation \"default$default.manager_keyword\" does not exist\n Position: 13"}}
prisma_1 | [Bugsnag - local / testing] Error report: com.bugsnag.Report@89ae9a8
prisma_1 | org.postgresql.util.PSQLException: ERROR: relation "default$default.manager_keyword" does not exist
This error is thrown during update and delete mutations too.
It seems that prisma looks for the table in default$default schema during mutations and public schema during queries.
Expected behavior
A clear and concise description of what you expected to happen.
Mutations should be executed on a given table in public schema instead of default$default schema when schema: public option is provided in docker-compose.yml.
Screenshots
If applicable, add screenshots to help explain your problem.
Versions (please complete the following information):
Ubuntu 18.04 LTSprisma/1.14.0-Beta (linux-x64) node-v8.11.3docker-compose version 1.22.0, build f46880feAdditional context
Add any other context about the problem here.
1) Other logs related to default$default schema from docker-compose up:
prisma_1 | [Metrics] No Prisma Cloud secret is set. Metrics collection is disabled.
prisma_1 | [Debug] Initializing deployment worker for default$default
prisma_1 | [Debug] Scheduling deployment for project default$default
prisma_1 | Warning: Management API authentication is disabled. To protect your management server you should provide one (not both) of the environment variables 'CLUSTER_PUBLIC_KEY' (asymmetric, deprecated soon) or 'PRISMA_MANAGEMENT_API_JWT_SECRET' (symmetric JWT).
prisma_1 | [Debug] Applied migration for project default$default
2) The create mutation works if a new manager_keyword table is created in default$default schema. But this is not helpful since queries are executed on a table in public schema and mutations are executed on a different table in default$default schema
3) If schema: public option is not provided in docker-compose.yml, then all queries and mutations work as expected in default$default schema.
Thanks for reporting! I implemented a bugfix and just triggered a new release/
The release is 1.13.7 and will be availabel in a few minutes: https://github.com/prismagraphql/prisma/releases/tag/1.13.7
Most helpful comment
Thanks for reporting! I implemented a bugfix and just triggered a new release/
The release is
1.13.7and will be availabel in a few minutes: https://github.com/prismagraphql/prisma/releases/tag/1.13.7