Repository navigation
Default generate to PGlite so db:generate works without a running Postgres - #102
Open
metallicmonkey365 wants to merge 4 commits into
Open
metallicmonkey365 wants to merge 4 commits into
metallicmonkey365 wants to merge 4 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2
@algora-pbc /claim #2
Summary
bun run db:generatein a freshly scaffolded project no longer needs a Postgres server running in the background. Generation defaults to the existing PGlite path (added in #7) at every level:src/generate.ts—generate()now defaultspglitetotrue. The temporary gateway server and PGlite instance are closed andDATABASE_URLis restored in afinallyblock, so a failed run no longer leaks the socket server or leaves the env override behind.src/cli.ts—--pglitedefaults totrue(documented in--help);--no-pgliteis the explicit opt-out for generating from an external Postgres viaDATABASE_URL. The command now awaitsgenerate().src/init.ts—pgstrap initscaffoldsdb:generateaspgstrap generate --pgliteand addsdb:generate:postgres(pgstrap generate --no-pglite) so the opt-out is discoverable in scaffolded projects.README.md— documents the new default and the opt-out.Tests
New
tests/generate.default-pglite.test.ts(the existing explicit---pglitetest is untouched):generate()succeeds withDATABASE_URLpointing at an unreachable database — proving no external Postgres is involved — and restores the caller'sDATABASE_URLpglite: falsereally takes the external path (run in a subprocess: it fails withECONNREFUSEDagainst an unreachableDATABASE_URLinstead of falling back to PGlite)DATABASE_URLVerification:
bun test— 6 pass, 0 failbun run build— successbun run format:check— cleanpgstrap initscaffolds both scripts;pgstrap generatewith an unreachableDATABASE_URLexits 0 and writes types + structure;pgstrap generate --no-pgliteexits 1 withECONNREFUSED