(Error) .. message: "relation "prisma-hello.User" does not exist"
See original GitHub issueCreated a basic setup, following the Prisma2 docs and tutorial, however, I get the Error mentioned in title. (full output below)
project.prisma:
datasource db {
provider = "postgresql"
url = "postgresql://user:password@ec2-174-ha-ha-205.compute-1.amazonaws.com:5432/xxxxxxx?schema=prisma-hello"
}
generator photonjs {
provider = "photonjs"
}
model User {
id Int @id
createdAt DateTime @default(now())
email String @unique
name String?
}
index.ts:
import Photon from '@generated/photon';
const photon = new Photon();
async function main() {
console.log('[Got in] index.ts');
// Open connection to database
await photon.connect();
console.log('[photon.connected in] index.ts');
const newUser = await photon.users.create({
data: {
name: 'Alice',
email: 'alice@prisma.io'
}
});
console.log(newUser);
const allUsers = await photon.users.findMany();
console.log(allUsers);
// Close connection to database
await photon.disconnect();
}
main();
Full error output:
─➤ npm start
> hello-prisma@1.0.0 start /Users/ScottAgirs/../starters/hello-prisma
> ts-node index.ts
[Got in] index.ts
[photon.connected in] index.ts
(node:8492) UnhandledPromiseRejectionWarning: Error: Error in Photon:
[
{
"error": "ConnectorError(QueryError(Error { kind: Db, cause: Some(DbError { severity: \"ERROR\", parsed_severity: Some(Error), code: SqlState(\"42P01\"), message: \"relation \\\"prisma-hello.User\\\" does not exist\", detail: None, hint: None, position: Some(Original(13)), where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some(\"parse_relation.c\"), line: Some(1159), routine: Some(\"parserOpenTable\") }) }\n\nstack backtrace:\n 0: backtrace::backtrace::trace::h5511721bea6fa8d5 (0x10f346cce)\n 1: backtrace::capture::Backtrace::new_unresolved::h28f9c9663a9420c8 (0x10f345e28)\n 2: failure::backtrace::internal::InternalBacktrace::new::hbb41405b6d19ab81 (0x10f345799)\n 3: <failure::backtrace::Backtrace as core::default::Default>::default::h0458ad281d4247c8 (0x10f345985)\n 4: <sql_connector::error::SqlError as core::convert::From<tokio_postgres::error::Error>>::from::h4d6632d810ab6f89 (0x10ec6f69c)\n 5: sql_connector::database::postgresql::<impl sql_connector::transactional::Transaction for postgres::transaction::Transaction>::write::ha2ca1483a41de8e3 (0x10ec455f5)\n 6: sql_connector::transactional::Transaction::insert::h102a04439344ffff (0x10e855964)\n 7: sql_connector::transactional::database_writer::create::execute::h2c63144580998c8d (0x10ec83b31)\n 8: sql_connector::transactional::database_writer::<impl connector::database_writer::DatabaseWriter for sql_connector::database::SqlDatabase<T>>::execute::{{closure}}::create::hef864a06474fbea9 (0x10ecc1d97)\n 9: <sql_connector::database::postgresql::PostgreSql as sql_connector::transactional::Transactional>::with_transaction::h9fe1ec452d2d39e2 (0x10e952dd8)\n 10: sql_connector::transactional::database_writer::<impl connector::database_writer::DatabaseWriter for sql_connector::database::SqlDatabase<T>>::execute::h292b3294dffefd85 (0x10e8d74d6)\n 11: core::executor::write::WriteQueryExecutor::exec_one::h48f2e807cc785823 (0x10ed722f6)\n 12: core::executor::write::WriteQueryExecutor::execute::h992b6a51be508cce (0x10ed71c4b)\n 13: core::executor::Executor::exec_all::h5cbc538ae21b3c80 (0x10ed90d94)\n 14: <prisma::req_handlers::graphql::GraphQlRequestHandler as prisma::req_handlers::RequestHandler>::handle::h7d76032243e11158 (0x10e9d7b7f)\n 15: prisma::http_handler::h5782a9905407eb5f (0x10e97250f)\n 16: <F as actix_web::with::FnWith<T,R>>::call_with::haa4a1a2255bc8611 (0x10e9cf813)\n 17: <actix_web::with::WithHandlerFut<T,S,R> as futures::future::Future>::poll::hd3a8444797502a6e (0x10e9d5b92)\n 18: actix_web::pipeline::PipelineState<S,H>::poll::h147d5d5368789f0e (0x10e8afc86)\n 19: <actix_web::pipeline::Pipeline<S,H> as actix_web::server::handler::HttpHandlerTask>::poll_io::h39e2cc76fc5e8dd4 (0x10e8a3150)\n 20: actix_web::server::h1::Http1Dispatcher<T,H>::poll_handler::hf7d43112cc4ed6f5 (0x10e878f8a)\n 21: actix_web::server::h1::Http1Dispatcher<T,H>::poll::h9c1da5bf8f5108dd (0x10e9481e3)\n 22: <actix_web::server::channel::HttpChannel<T,H> as futures::future::Future>::poll::had9f1b0a81e71dda (0x10e9470b9)\n 23: <actix_web::server::channel::HttpChannel<T,H> as futures::future::Future>::poll::had9f1b0a81e71dda (0x10e947f73)\n 24: <actix_net::service::and_then::AndThenFuture<A,B> as futures::future::Future>::poll::h15ac475c98adc942 (0x10e8a1a46)\n 25: futures::future::chain::Chain<A,B,C>::poll::hb6e62549216884f5 (0x10e89dcc4)\n 26: futures::task_impl::std::set::he4a7d579f87ab972 (0x10eab973d)\n 27: futures::task_impl::Spawn<T>::poll_future_notify::h1a5228822adb903e (0x10ead274f)\n 28: tokio_current_thread::CurrentRunner::set_spawn::h6965d5b16e375442 (0x10eab36b4)\n 29: tokio_current_thread::scheduler::Scheduler<U>::tick::h6c1934358ae3f6a8 (0x10eabfa45)\n 30: tokio_current_thread::Entered<P>::block_on::he3da6e046995d1e4 (0x10eab426a)\n 31: std::thread::local::LocalKey<T>::with::h6ed9ac0420a84d3b (0x10eaca944)\n 32: std::thread::local::LocalKey<T>::with::h71f7d0c12da0393f (0x10eacae87)\n 33: std::thread::local::LocalKey<T>::with::h10c82d1197b9368d (0x10eac8b6c)\n 34: std::thread::local::LocalKey<T>::with::h38bd3e3c53efd4ea (0x10eaca048)\n 35: tokio::runtime::current_thread::runtime::Runtime::block_on::hbad87c088a1c5a72 (0x10eab7ad2)\n 36: std::sys_common::backtrace::__rust_begin_short_backtrace::h690508ce542785d7 (0x10ead02e8)\n 37: std::panicking::try::do_call::h1536644c0a3cab79 (0x10eab5e3b)\n 38: __rust_maybe_catch_panic (0x10f3777bf)\n 39: core::ops::function::FnOnce::call_once{{vtable.shim}}::h3508efbc713fc3ba (0x10ead0b76)\n 40: <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::hf8766009c029bc09 (0x10f35e9be)\n 41: std::sys::unix::thread::Thread::new::thread_start::hfdef4649a42cf26c (0x10f376dbe)\n 42: _pthread_body (0x7fff6e2652eb)\n 43: _pthread_start (0x7fff6e268249)))"
}
]
at PhotonFetcher.<anonymous> (/Users/ScottAgirs/../starters/hello-prisma/node_modules/@generated/photon/index.js:35:23)
at Generator.throw (<anonymous>)
at rejected (/Users/ScottAgirs/../starters/hello-prisma/node_modules/@generated/photon/index.js:5:65)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:8492) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:8492) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
^C
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
SOLVED: Problem with existing DB - Questions - Prisma 1
Hello, I tested Prisma with AWS RDS (one small DB Instance of PostgreSQL on db.t2.micro). I local all works fine, but when I...
Read more >"Property does not exist" when I want to use model added in ...
I tried prisma generate and prisma migrate dev but was still having the same error. I had to restart VSCode and everything is...
Read more >How to Get Started with Prisma ORM for Node.js and ...
In this post, we will learn how to use Prisma with the Express.js ... There are multiple ways to run a PostgreSQL database...
Read more >type-graphql/prisma2 - Gitter
Hi ! Is there a way to add directives to the generated model types? ... When i run a graphql query, i'm getting...
Read more >Prisma queryRaw throws error when using template string ...
Invalid `prisma.queryRaw()` invocation: Raw query failed. Code: `42P01`. Message: `relation "$1" does not exist`. Below are Prisma logs from ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I don’t think this can be coupled into photon as it is just a database client and migrations are managed by lift.
I think you can easily solve this by a
preseed
script orpredev
script that would make sure that migrations are applied in development.For production, auto-running migrations can be catastrophic.
Have you run migrations before starting to query your data?
If not please run
prisma dev
. Otherwise, it won’t create an SQLite DB and will throw a connection error.