Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use relative path to MIGRATIONS_DIR instead of absolute? #195

Closed
alakhpc opened this issue Oct 30, 2022 · 4 comments
Closed

Use relative path to MIGRATIONS_DIR instead of absolute? #195

alakhpc opened this issue Oct 30, 2022 · 4 comments

Comments

@alakhpc
Copy link

alakhpc commented Oct 30, 2022

I'm trying to use the migrations, which inserts

pub static MIGRATIONS_DIR: &::prisma_client_rust::migrations::include_dir::Dir = &::prisma_client_rust::migrations::include_dir::include_dir!(
    "/Users/name/Projects/nwb2/migrations"
);

into the generated file. This however fails when you try and run it on another machine (or in docker).
Would it be better to store a relative path instead?

@alakhpc
Copy link
Author

alakhpc commented Oct 30, 2022

same for DATAMODEL_STR actually

@Brendonovich
Copy link
Owner

include_dir only allows resolving paths relative to $CARGO_MANIFEST_DIR, so a looot more work that I don't want to do would have to be done to calculate the relative path. Besides, the client isn't designed to be shared across machines and should be regenerated wherever it is needed (it shouldn't even be checked into git), so the absolute path changing should be allowed.

@brecht-derooms
Copy link

brecht-derooms commented Mar 8, 2023

Hi @Brendonovich , I had the same reflection as @alakhpc. Although I understand your logic, what would your guidance be for compiling code that uses the library in a CI? It appears the client is not meant to be portable. In case you want to compile the code that uses the client, is the recommendation to generate the client in the CI prior to building the code? I assume many might initially fall into the trap to commit the client when they get started and then find this issue.

PS: thanks for bringing Prisma to rust, great work!

Edit: I think I have my answer by looking at your github workflows, before the tests it says:

    - name: Generate client
      working-directory: integration-tests
      run: cargo prisma generate

@HuakunShen
Copy link

I have the same problem.

I use the prisma.rs in lib.rs

pub mod prisma;

If I don't include the prisma.rs in git, then cargo prisma generate will fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants