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

Prisma CLI version mismatch #1099

Closed
steebchen opened this issue Nov 11, 2023 · 0 comments · Fixed by #1100
Closed

Prisma CLI version mismatch #1099

steebchen opened this issue Nov 11, 2023 · 0 comments · Fixed by #1100

Comments

@steebchen
Copy link
Owner

steebchen commented Nov 11, 2023

If you are using the Go client in addition to another client or if you use npx prisma generate to generate the Go client, you might run into a version mismatch. This happens due to the fact that the Prisma NodeJS CLI version differs than what is shipped in the Go client.

To fix this, you need to either make sure the version is the same, or use the Go command to generate the Go client.

The difference

npm / prisma-client-js

npx prisma generate

Using this command to generate the Go client might result in a version mismatch.

go command

go run github.com/steebchen/prisma-client-go generate

This command is consistent as the Prisma version is defined in your go.mod file.
The command and the actual generator is guaranteed to be the same version, because the Go client ships with the Prisma CLI.

If you are using 2 generators

If you currently use two generators, such as prisma-client-js and the Go client, you have two options. You can either make sure the Prisma CLI version matches the Prisma Go client CLI version, or you can use the go command to generate the Go client, and the JS command to generate the JS client separately.

a) Make sure the version matches

Run these:

npx prisma version
# and
go run github.com/steebchen/prisma-client-go version

If the version mismatches, find a Go client release that uses the Prisma version, or change your Prisma version in your package.json to match the Go client Prisma version.

b) Use the Go command

Alternatively, you can use the Go command to generate your Prisma version, regardless of what version you are using for the JS client.

If you currently have two generators in your schema.prisma file, you need to change it to one and dynamically change the generator.

Change this:

generator client_js {
  provider = "prisma-client-js"
}

generator client_go {
  provider = "go run github.com/steebchen/prisma-client-go"
  output   = "../../worker/prisma/"
}

To this:

generator client {
  provider = env("GENERATOR_PROVIDER")
  // optionally provide more configuration options
  output   = env("GENERATOR_OUTPUT")
}

And then run as follows:

GENERATOR_PROVIDER="go run github.com/steebchen/prisma-client-go" go run github.com/steebchen/prisma-client-go
# or
GENERATOR_PROVIDER="prisma-client-js" npx prisma generate
@steebchen steebchen changed the title Version mismatch Prisma CLI version mismatch Nov 11, 2023
@steebchen steebchen linked a pull request Nov 11, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging a pull request may close this issue.

1 participant