How to share prisma's schema over packages, while ...
# orm-help
u
How to share prisma's schema over packages, while keep only one copy of it?
e
It depends 🙂 If you are just talking about
prisma.schema
, and using polyrepo approach, you might want to write a script to copy the file from the original location to other repos. If you are using webpack, you can add a plugin to copy the schema file to other directories everytime a build happens. There could be other ways as well. I normally see people just share the generated prisma client so there’s only one source for the schema. In this case, if you are using a monorepo, you can import it to packages where you need it. If you are using polyrepo, you might have to publish an npm package and install it where you need it.
👍 1
u
thanks. but it seems still not very convenient🙂
e
Do you have multiple backends and need to talk to the same DB?
u
I have multiple pakcages wants to share the same db.
n
@李白字一日 did you consider using a monorepo, e.g. using Yarn workspaces or Lerna? With that approach, it should be fairly straightforward to share types across different packages 🙂
u
It seems duplicate schemas is more acceptable to me.😂
👍 2