-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat(prisma): support pglite in developer environments #338
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Datadog ReportBranch report: ✅ 0 Failed, 13 Passed, 0 Skipped, 10.03s Total Time |
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.
Keeping sane inside Pulau Tekong
a01e5af
to
ce1b6c6
Compare
ce1b6c6
to
cf7a550
Compare
Make pglite part of the core codebase, so that we can use it in environments where postgres may not be available, such as in browser-only environments like StackBlitz. - Rename prisma -> prisma/index to host submodules - Move pglite-related logic to pglite - Wrap actual init of PGlite as factory, and not within module load - Rework vitest.setup to depend on new submodule - Keep resetDb, since that is only useful to testing
cf7a550
to
bc5858a
Compare
If `NODE_ENV` is set to `development`, but no `DATABASE_URL` is given, we are likely in an environment which has no database, so fallback on using pglite.
bc5858a
to
07fe036
Compare
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 don't know if starter kit should be using pglite for development (and couple more code to the node environment). Does not seem like a useful thing for OGP folks. We want to stop tailoring this kit for external use at the expense of internal use!
@karrui but is it really at the expense of internal use? Granted this PR (and a few more I have planned) would add a few more moving parts, mostly properties or logic driven by |
I think the important thing for this starter kit is for it to be tight. Users already have to delete so many things to get it to a clean slate; and I want to reduce unnecessary code in the code base. I'd rather you update the docs to add this as a possibility if one does not have the propensity to spin up a database for use. However, I don't want to recommend people to use pglite in development either; you can't really connect to the db and explore the db as one would a real database. |
Okay, that's unfortunate but fair. I'll see how I can have this documented. |
Problem
In some local dev environments, we may not be able to connect to a postgres instance, for the following non-exhaustive reasons:
Solution
In such instances, we will allow for use of pglite, if
NODE_ENV
isdevelopment
ortest
, and there is noDATABASE_URL
specified. If both conditions hold, we inject a placeholder database url to placate prisma, and set up a PGLite adapter.Testing evidence