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

pglite-adapter #23877

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

pglite-adapter #23877

wants to merge 2 commits into from

Conversation

BLamy
Copy link

@BLamy BLamy commented Apr 17, 2024

Work in progress

@BLamy BLamy requested a review from a team as a code owner April 17, 2024 06:25
@BLamy BLamy requested review from Jolg42 and removed request for a team April 17, 2024 06:25
@CLAassistant
Copy link

CLAassistant commented Apr 17, 2024

CLA assistant check
All committers have signed the CLA.

@dthyresson
Copy link

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:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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"
Copy link

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?

Suggested change
provider = "postgresql"
provider = "pglite"

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?

Copy link

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'

Copy link

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.

Copy link
Author

@BLamy BLamy Apr 17, 2024

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)

@samwillis
Copy link

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)

@dthyresson
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants