Danny Nemer
10/05/2021, 3:21 AMgit pull
, they must then run prisma generate
to update their local environment for any schema changes others may have made.
I’m surprised this is the default expectation because it is a hassle.
We could create a git-hook to automatically regenerate on every pull
, but it would be simpler to check-in the generated-client-code and add a CI check that ensures the client-code is up-to-date.Ryan
10/05/2021, 6:18 AMDanny Nemer
10/05/2021, 6:14 PMprisma generate
because another team member can make changes to the DB model/schema almost daily? Otherwise, any local env’s TypeScript will throw errors for out-of-sync client code. If so, I’m curious to know the design decision for why the generated code is excluded from version control. Seems like it prevents routinely breaking dev environments with no downsides. Thank you!Ryan
10/06/2021, 5:25 AMprisma generate
if you don’t have it in version control, otherwise there’s no diff.Mischa
10/06/2021, 6:51 AMRussell Ormes
10/06/2021, 9:00 AMDanny Nemer
10/06/2021, 9:42 PMGenerated code would always be the same given the same schema on the same Prisma version so you would only need to run an extra@Ryan How would the client code be generated (for your local environment) without runningif you don’t have it in version control, otherwise there’s no diff.prisma generate
prisma generate
and without syncing the generated code via version control?Ryan
10/07/2021, 4:27 AMprisma generate
Danny Nemer
10/07/2021, 6:25 PMYou need@Ryan I thought so. Hence, as mentioned in the initial post, whenever a developer working in the codebase runsprisma generate
git pull
, they must then run prisma generate
to update their local environment for any schema changes others may have made. Right?Danny Nemer
10/07/2021, 6:34 PMA second is that the binaries are platform dependant, so unless all devs and all deploy environments are on the same platform, you might get issue with not building the client for your specific environment.@Russell Ormes Thank you for sharing this! I was unaware. However, I assumed the only code that differs is the generated JS (the
DMMF
, as Prisma calls it), which wouldn’t be platform dependent.
But, from inspecting my local node_modules/.prisma/client/
, I see there is libquery_engine-darwin.dylib.node
, a 35.8 MB file! Any idea what that file is?Ryan
10/08/2021, 5:41 AMHence, as mentioned in the initial post, whenever a developer working in the codebase runsYes., they must then rungit pull
to update their local environment for any schema changes others may have madeprisma generate
But, from inspecting my localThat is the Prisma binary that helps with querying and managing connections to the database. You can read more about that in our docs 🙂, I see there isnode_modules/.prisma/client/
, a 35.8 MB file! Any idea what that file is? (edited)libquery_engine-darwin.dylib.node
Russell Ormes
10/08/2021, 7:21 AMprisma generate
I guess this might be automated with some postinstall
scripts, although I know yarn
in particular does not encourage that pattern.Danny Nemer
10/09/2021, 5:52 AMprisma generate
produces multiple files. One is the client-specific binary. Another is the client-generated DMMF JS, which is small in size. It makes sense to commit the latter to version control because otherwise whenever a developer changes the schema, breaks the environment for all other engineers until they re-generate.
A postinstall
would only work whenever a user re-runs `yarn install`; however, the user is exposed to their environment breaking (or, in TS, not compiling) whenever any schema code changes.
Ideally, we could specify the output path for just the DMMF. Then, anyone on the team can change the schema without breaking the dev environments of the other engineers. This would be separate from the binary (which is separate from the schema), so this is consistent for all platforms and deployments.
No different than storing a schema.graphql
, also a generated file, in version control.