Skip to content

feat: raw pg provider#55

Draft
wellsm wants to merge 6 commits into
sbalmt:mainfrom
wellsm:feat/raw-pg-provider
Draft

feat: raw pg provider#55
wellsm wants to merge 6 commits into
sbalmt:mainfrom
wellsm:feat/raw-pg-provider

Conversation

@wellsm

@wellsm wellsm commented May 15, 2026

Copy link
Copy Markdown
Contributor

Summary

New @ez4/raw-pg provider — point EZ4 services at any Postgres reachable
over 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. Exports PostgresEngine from
    @ez4/raw-pg/client (mirrors Aurora). Emulator + deploy triggers
    share the same getUpdateQueries migration logic, applied via a
    stateful raw:pg.migration step.
  • @ez4/pgclientClientConnection accepts an optional
    connectionString; 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, propagated
to the Lambda as a runtime env var.

Limitations

  • Connection string lives in plaintext Lambda env (Secrets Manager swap is
    future scope).
  • No CREATE DATABASE; reset is table-scoped.

wellsm and others added 5 commits May 15, 2026 14:26
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>
@sbalmt sbalmt changed the base branch from main to v0.48.0 May 16, 2026 13:06
@sbalmt sbalmt changed the title Feat/raw pg provider feat: raw pg provider May 16, 2026
Match the boilerplate every other provider package ships.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sbalmt sbalmt changed the base branch from v0.48.0 to main June 2, 2026 20:44
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.

1 participant