prisma-client-rust icon indicating copy to clipboard operation
prisma-client-rust copied to clipboard

Include schema by relative path.

Open Toasterson opened this issue 1 year ago • 3 comments

I develop both on a Mac and and my linux computer.

On my linux computer I get the following error:

error: couldn't read /Users/toasty/ws/oxifed/prisma/schema.prisma: No such file or directory (os error 2)
 --> src/prisma.rs:4:5
  |
4 |     include_str!("/Users/toasty/ws/oxifed/prisma/schema.prisma");
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in the macro `include_str` (in Nightly builds, run with -Z macro-backtrace for more info)

error: could not compile `oxifed` (lib) due to previous error

I had to delete prisma.rs and make an empty prisma.rs to be able to run prisma generate

Unless relative paths are used the generated prisma.rs file is machine dependant and user dependant which is not usable with CI.

Toasterson avatar Jan 09 '24 10:01 Toasterson

From the docs:

The generated client must not be checked into source control. It cannot be transferred between devices or operating systems. You will need to re-generate it wherever you build your project. If using git, add it to your .gitignore file.

Migrations require using an absolute path, so for consistency I've made the schema do the same.

Brendonovich avatar Jan 09 '24 10:01 Brendonovich

Well in migrations you can still be changed by the program. The Rust source always assume relative path so hardcoding fixed paths breaks rust tooling. No crate with prisma can be distributed at all.

Toasterson avatar Jan 29 '24 09:01 Toasterson

Well in migrations you can still be changed by the program

Migrations are embedded into the binary at build-time, not sure I get your point

The Rust source always assume relative path so hardcoding fixed paths breaks rust tooling

I'll gladly accept a PR switching to relative paths for schema + migrations but I probably won't be the one to write it

No crate with prisma can be distributed at all

Haven't seen this use case before, I work in monorepos and workspaces - can you generate the client in a build script for whoever consumes the package?

Brendonovich avatar Jan 29 '24 09:01 Brendonovich