fix: fall back to pglite for type generation#43
Open
sclee980528-prog wants to merge 1 commit into
Open
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.
Problem
pgstrap generatestill required a reachable Postgres server unless users remembered to pass--pglite. That means the defaultbun run db:generatescript scaffolded by pgstrap could fail on a machine without local Postgres running.Approach
generatedefault to anautomode: use the configured Postgres database when it is reachable, and fall back to PGlite only when the connection is unavailable.pgstrap generate --pgliteforces the embedded PGlite flow.pgstrap generate --no-pgliterequires real Postgres and disables fallback.pg-gatewaywire-protocol bridge so Zapatos andpg-schema-dumpcan introspect through normal Postgres clients.DATABASE_URLand close the temporary bridge server, sockets, and PGlite instance after generation.Verification
npm_config_cache=/private/tmp/bounty-pgstrap-npm npx --yes bun@1.2.21 testnpm_config_cache=/private/tmp/bounty-pgstrap-npm npx --yes bun@1.2.21 run format:checknpm_config_cache=/private/tmp/bounty-pgstrap-npm npx --yes bun@1.2.21 run buildgit diff --checkpostgresorpostmasterprocess was running withpgrep -fl 'postgres|postmaster'.bun run db:generatewithDATABASE_URLandPG*env vars unset.Postgres unavailable; generating with PGlite.src/db/zapatos/schema.d.ts.src/db/structure/public/tables/widgets/table.sql.--pgliteoutput for the same fixture.Usage
Default behavior now works without local Postgres:
Force PGlite:
Require real Postgres:
@algora-pbc /claim #2