Include schema by relative path.
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.
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.
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.
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?