Skip to content

Generate offline with PGlite by default, including Windows and URI-configured projects - #54

Open
lucerowebcrafters wants to merge 1 commit into
seveibar:mainfrom
lucerowebcrafters:fix/offline-pglite-generation
Open

Generate offline with PGlite by default, including Windows and URI-configured projects#54
lucerowebcrafters wants to merge 1 commit into
seveibar:mainfrom
lucerowebcrafters:fix/offline-pglite-generation

Conversation

@lucerowebcrafters

Copy link
Copy Markdown

Fixes #2.

pgstrap generate now runs migrations in a temporary PGlite database by default, so the scaffolded db:generate script does not require a running PostgreSQL server. --no-pglite retains generation from the configured PostgreSQL database.

Two reproduced failures are also fixed:

  • The packaged Node CLI failed on Windows with ERR_UNSUPPORTED_ESM_URL_SCHEME when importing its configuration. The import now uses a file URL, including for paths containing spaces or #.
  • POSTGRES_URI and PG_URI overrode the temporary DATABASE_URL, redirecting schema dumps to an external server even with PGlite enabled. Dumping now uses the temporary database through the resolver's highest-priority input and restores that setting afterward.

Generation calls are serialized because the dump dependency reads process-wide environment variables. Cleanup restores that environment and closes the temporary database, loopback listener, and sockets on success or failure. The CLI awaits completion and reports failures through its command handler.

Validation on Windows with Node 22.14.0 and Bun 1.2.6: seven tests pass, the production build passes, and formatting passes for the sixteen version-controlled source/configuration files. New tests run the built Node CLI, inspect generated TypeScript and SQL, verify the explicit PostgreSQL opt-out, recover from a dump failure, and check concurrent schema isolation. Baseline migration tests still emit the pre-existing Windows path warnings despite passing; the built CLI's configuration-import failure was separately reproduced and fixed.

This contribution was prepared with AI assistance. Is the advertised $30 bounty still available for this submission?

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