fix: default db:generate to PGlite so Postgres is not required - #49
Open
adsqx wants to merge 1 commit into
Open
Conversation
Flip --pglite default to true (with --no-pglite escape hatch), await the generate CLI handler, close the in-memory server in finally, and scaffold the init script with --pglite.
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.
@algora-pbc /claim #2
Fixes #2 —
db:generateno longer needs a Postgres server running.generatealready had a working PGlite path, it was just off by default. This PR flips the default instead of adding new machinery:src/cli.ts:--pglitenow defaults totrue, so yargs gives you--no-pgliteas the escape hatch for generating against a real database. The handler nowawaitsgenerate(), which it previously did not — without that the CLI could exit before generation finished.src/generate.ts:pglitedefaults totrueso programmaticgenerate(ctx)behaves like the CLI, and the PGlite TCP server is closed (andDATABASE_URLrestored) in afinallyblock so a failed generation cannot leak a listening socket.src/init.ts: scaffoldspgstrap generate --pglite— explicit intent in new projects even though the CLI default already covers it.npm run db:generateuses in-memory PGlite and needs no Postgres, plus--no-pglitefor an existing database.init.test.tsupdated; a short test in the existinggenerate.pglite.test.tsasserts the default path generates types with no server running.Why this over the other open PRs: changing only the init script leaves every already-initialized project still running
pgstrap generateagainst a Postgres that isn't there, so the issue isn't actually fixed for them. Adding a separatedb:generate:postgresscript invents surface the issue didn't ask for, and the larger rewrites (env sniffing, restructuredgenerate.ts, lockfile churn) change far more than the bug requires. This is 5 files, no new dependencies, no reformatting noise.bun testandbun run format:checkare green.