I've been thinking about building a shared Prisma ...
# orm-help
e
I've been thinking about building a shared Prisma client through an internal npm package. So I can maintain one schema/client but use it throughout different services. I'm thinking it through and I struggle to see if it's possible. How can I run a client in development with a development DB and a development-specific DB (experimental schema) without having to push to main?
j
You could clone the DB repo and use
npm link
to have your repo use the local copy instead of the actual package
e
I got two services using Prisma. Is it bad if I just copy and paste schema/migration changes to the non-changed service?
j
You can, but I wouldn't - that seems error prone
e
Is the only other option really a monorepo?
or internal package
j
I mean, either the code needs to be within the same repo (either because its a monorepo or you copy across), or it needs to be in some other repo
e
Yeah
Okay
Thank you, I'm going to try an internal package.
So when in development, I will clone it and instead of importing the published package, I link it instead?
j
You could technically have a github repo itself as a dependancy, but then you either need to commit the generated client (which feels kinda gross) or build it from the consuming package (which seems liable to create build complexity)
Basically it allows you to override a dependency with a local copy
🙌 1
e
Realistically a DB package would just be something that generates and exports the Prisma client based off the schema, right?
It also will hold migrations
j
I would imagine so, yeah
e
Cool