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
pglite-adapter #23877
base: main
Are you sure you want to change the base?
pglite-adapter #23877
Conversation
Hi @BLamy many thanks for getting this started. I was just talking to Electric SQL and Prisma about just this very need. We on the RedwoodJS Core Team are really excited about using PGLite. Happy to help test or pitch in if anything you need to complete. |
|
||
### 1. Enable the `driverAdapters` Preview feature flag | ||
|
||
Since driver adapters are currently in [Preview](/orm/more/releases#preview), you need to enable its feature flag on the `datasource` block in your Prisma schema: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since driver adapters are currently in [Preview](/orm/more/releases#preview), you need to enable its feature flag on the `datasource` block in your Prisma schema: | |
Since driver adapters are currently in [Preview](/orm/more/releases#preview), you need to enable its feature flag in the `generator client` block in your Prisma schema: |
} | ||
|
||
datasource db { | ||
provider = "postgresql" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be pglite
instead?
provider = "postgresql" | |
provider = "pglite" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Tobbe I wondered that myself but if you look at the Neon adapter https://github.com/prisma/prisma/tree/main/packages/adapter-neon it specifies ‘postgres’ and in the PlanetScale adapter ‘mysql’ so it might be the underlying provider?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. I went off of the new provider added here
https://github.com/BLamy/prisma/blob/bd007e4b5f2cc2063d828c2325642de4d3388f70/packages/driver-adapter-utils/src/types.ts#L86
readonly provider: 'mysql' | 'postgres' | 'sqlite' | 'pglite'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’d have to check with the Prisma team by I thought of it as “flavor” and “client” — meaning this flavor of SQL and the features it supports is “postgres” (for example arrays and enums are supported — how you define your schema etc ), but the client used to make queries etc is the adapter “pglite”. But still learning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I was a little confused by this. I think what I want is that I want postgres to be used on both prod and dev. But if NODE_ENV=test I want it to be pglite.
Not sure if that goal aligns with what everyone else wants (or even if it's a good goal for that matter)
Hey @BLamy, If you come across anything broken/odd with PGlite, or have any questions, do give me a shout. I'm very happy to help make this happen! (I work on PGlite) |
@samwillis and @BLamy Having spoken a little more with Prisma, we may want to make this a third-party integration (separate repo). It would speed up getting the adapter in peoples' hands to try out. I was pointed to https://github.com/tidbcloud/prisma-adapter as one example of a such an adapter as a pattern to follow. |
Work in progress