Skip to content

feat: default to pglite so external postgres is not required for db:generate (#2) - #117

Open
MilindChatrabhuji wants to merge 1 commit into
seveibar:mainfrom
MilindChatrabhuji:fix/default-pglite-without-external-postgres-2
Open

MilindChatrabhuji wants to merge 1 commit into
seveibar:mainfrom
MilindChatrabhuji:fix/default-pglite-without-external-postgres-2

Conversation

@MilindChatrabhuji

Copy link
Copy Markdown

Fixes #2

Problem

Running \�un run db:generate\ previously failed if a Postgres daemon was not actively running on the system because \pglite\ defaulted to \ alse\ in both \cli.ts\ and \generate.ts.

Solution

  1. Default to PGlite: In \src/cli.ts\ and \src/generate.ts, defaulted \pglite\ to \ rue. If no external Postgres is configured or running, \pgstrap generate\ automatically spins up the in-memory PGlite instance via \pg-gateway, runs migrations, and generates Zapatos types and schema dumps with zero external background processes.
  2. Configuration Support: Added optional \pglite?: boolean\ to \PgstrapConfig\ in \src/define-config.ts\ allowing users to explicitly override or configure their preference in \pgstrap.config.js.
  3. Automated Test Coverage: Added \ ests/generate.default-pglite.test.ts\ verifying that calling \generate()\ with no live Postgres daemon and default options executes migrations, creates Zapatos types, and writes SQL table structures seamlessly.

Test Results

All 4 test suites passing:
\\�ash
bun test
✓ generate defaults to pglite without requiring external postgres daemon
✓ generate with pglite runs migrations and dumps structure
✓ initPgstrap writes scripts to package.json
✓ migration of a pglite db works
4 pass, 0 fail, 10 expect() calls
\\

@algora-pbc /claim #2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use pglite so that postgres isn't required when generating types

1 participant