Brendonovich / prisma-client-rust

Type-safe database access for Rust
https://prisma.brendonovich.dev
Apache License 2.0
1.76k stars 104 forks source link

table doesn't exist #278

Closed chronicl closed 1 year ago

chronicl commented 1 year ago

I'm getting the following error when trying to use sqlite as the database

thread 'main' panicked at 'called Result::unwrap() on an Err value: Execute(Error { is_panic: false, inner: Known(KnownError { message: "The table main.User does not exist in the current database.", meta: Object {"table": String("main.User")}, error_code: "P2021" }), batch_request_idx: None })', src\bin\main.rs:18:10

Here is a repo for reproducibility https://github.com/chronicl/prisma-client-rust-bug .

I saw #28 and tried moving the schema.prisma file into the root without success.

oscartbeaumont commented 1 year ago

I don't think #[cfg(debug)] is valid, I think it was intended to be #[cfg(debug_assertions)]. playground

I will do a PR to fix that now.

It's worth noting that #[cfg(debug_assertions)] means the next line will only run the database migrations in non-release builds. Eg. If you do cargo run --release it will skip the _db_push call and you will run into the same issue as you have right now, it is done this way in the example because for most production use cases you will want to use the Prisma CLI to manage migrations instead of them being automatic.