feat: make pglite default for generate without requiring external postgres - #64
Open
iprasen wants to merge 1 commit into
Open
feat: make pglite default for generate without requiring external postgres#64iprasen wants to merge 1 commit into
iprasen wants to merge 1 commit into
Conversation
- Default generate() to use pglite: true - Default CLI generate command option pglite to true with --no-pglite opt-out - Ensure socket server, PGlite instance, and DATABASE_URL cleanup in try...finally - Await generate() in CLI handler to properly propagate async execution - Add comprehensive tests for default pglite execution, opt-out, and cleanup
Author
|
@algora-pbc /claim #2 |
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.
Overview
Fixes #2.
Claims Algora bounty:
@algora-pbc /claim #2
Problem
Previously, running
bun run db:generateorpgstrap generatedefaulted to connecting to an external PostgreSQL instance unless--pglitewas explicitly supplied. When running in environments without PostgreSQL running in the background, type generation failed.Solution
pglitetotrueingenerate():generate()now defaults topglite = true, running migrations in a temporary in-memory PGlite instance and dumping structure without requiring external PostgreSQL.pglitetotrue:pgstrap generate(and thusbun run db:generate) works immediately out of the box.pgstrap generate --no-pglite.try ... finallyblock so thatserver.close(), PGlite disposal, andprocess.env.DATABASE_URLrestoration always run even if type generation or tree dumping fails.await generate(...)in the CLI action handler to ensure errors are propagated and asynchronous execution finishes before exiting.generatedefaulting to PGlite when the option is omitted.generateopting out to external Postgres whenpglite: false.DATABASE_URLrestoration and socket server cleanup when errors occur.