feat: raw pg provider#55
Draft
wellsm wants to merge 6 commits into
Draft
Conversation
New @ez4/raw-pg provider lets EZ4 services target any Postgres-compatible server reachable via TCP (Supabase, Neon, RDS direct) instead of being locked to AWS Aurora. v0.1 ships local emulator + migration triggers: declare engine `name: 'raw-pg'`, set `localOptions.<service>.connectionString`, and `ez4 serve` runs `getUpdateQueries` against the live database. @ez4/pgclient `ClientConnection` now accepts an optional `connectionString` and treats host/user/password as optional so the same pool builder serves both URL and per-field configs without breaking Aurora's local mode. Prod-deploy linkage (`prepareLinkedService`/`prepareResources`) deferred to v0.2 — current scope is dev/migrations only as requested. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Production deploy support for raw-pg: prepareResources claims the service without creating AWS resources, prepareLinkedService emits a ContextSource that reads EZ4_RAW_PG_<SERVICE>_URL from deploy-time env and propagates it to the consuming Lambda as a runtime env var. The Lambda then constructs @ez4/raw-pg/client with that connection string. hello-raw-pg shows the full setup: ez4.project.js wires localOptions for dev, env propagation for prod; example.env documents the var naming convention; README covers dev/deploy paths and current limitations (plaintext env, no CREATE DATABASE, table-scoped reset). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Move @ez4/raw-pg from providers/external to providers/raw to match the folder=package-prefix convention (providers/aws/aws-aurora, providers/local/local-database, providers/raw/raw-pg). Production migrations now run during deploy. prepareResources attaches a raw:pg.migration state entry whose handler opens a TCP connection using EZ4_RAW_PG_<SERVICE>_URL and applies getUpdateQueries (same diff logic as ez4 serve, persisted in the deploy state file). create, update, replace, and delete steps mirror @ez4/aws-aurora's migration provider so force/preview/destroy behave consistently. Adds @ez4/aws-common dep for the shared step-handler registry — the deploy pipeline reads from it, so any provider that wants its state entries applied must register through tryRegisterProvider. Package README documents engine declaration, env-var convention, dev and deploy flows, and current limitations (plaintext env, no CREATE DATABASE, table-scoped reset). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mirror @ez4/aws-aurora's naming: engine type is `PostgresEngine` exported from `@ez4/raw-pg/client` (was `RawPgEngine` from main). Aurora and raw-pg are never used together in the same service — when they coexist in one project, callers alias the import. The runtime `engine.name` discriminator (`'aurora'` vs `'raw-pg'`) stays unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Without a per-package .npmignore, npm falls back to the repo .gitignore, which excludes dist/ — so the published tarball shipped without compiled output and consumers got "module not found" at runtime. Match the whitelist pattern used by @ez4/aws-aurora and @ez4/pgclient. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Match the boilerplate every other provider package ships. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
New
@ez4/raw-pgprovider — point EZ4 services at any Postgres reachableover TCP (Supabase, Neon, Railway, RDS direct, self-hosted) instead of
provisioning AWS Aurora.
Motivation
Aurora cost. Managed Postgres providers (Supabase free tier, Neon, etc.)
solve the same problem for a fraction of the price, and many teams already
pay for one. This provider lets EZ4 ride on top without giving up
schema-as-types, diff migrations, or the typed query API.
What changes
providers/raw/raw-pg— new package. ExportsPostgresEnginefrom@ez4/raw-pg/client(mirrors Aurora). Emulator + deploy triggersshare the same
getUpdateQueriesmigration logic, applied via astateful
raw:pg.migrationstep.@ez4/pgclient—ClientConnectionaccepts an optionalconnectionString; per-field config still works (Aurora untouched).examples/hello-raw-pg— minimal seed.Env convention
EZ4_RAW_PG_<SERVICE_NAME_SNAKE_UPPER>_URL— required at deploy, propagatedto the Lambda as a runtime env var.
Limitations
future scope).
CREATE DATABASE; reset is table-scoped.