Skip to content

NF2: the data plane from Terraform, the schema through db-migrate - #3

Merged
ruehowl merged 1 commit into
mainfrom
nf/2-data-plane
Oct 28, 2026
Merged

ruehowl merged 1 commit into
mainfrom
nf/2-data-plane

Conversation

@ruehowl

@ruehowl ruehowl commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

The infrastructure the three Workers bind, and the schema they read.

Terraform roots (one per environment, each publishing what the Workers render their config from)

  • infra/terraform/supabase — a Supabase project; ref, password and URL as Orun secrets (saas-starter's root).
  • infra/terraform/cloudflare-hyperdrive — a Hyperdrive config over that Postgres → WIRING_CLOUDFLARE_HYPERDRIVE (saas-starter's root).
  • infra/terraform/cloudflare-r2 — the storage bucket → WIRING_CLOUDFLARE_R2 (blob-starter's root).
  • infra/terraform/cloudflare-kv — the rate-limit namespace → WIRING_CLOUDFLARE_KV (kv-redis-starter's root).

The schema — prisma migrate replaced by packages/db (@app/db: checksummed migrations and saas-starter's Management-API runner) applied by infra/db-migrate:

  • 010_pages — upstream's one Prisma model, the stub Page, under Prisma's own table and key names.
  • 020_row_level_security — RLS with no policies on every table in public: closed to Supabase's Data API (anon, authenticated), open to the apps, which own the table; it refuses to run if that would lock the apps out.

Order on a merge (enforced; advisory on a pull request): app waits on Hyperdrive, R2 and the migrations; api on Hyperdrive and the migrations; web on KV. orun plan (push to main, stage):

supabase → cloudflare-hyperdrive → db-migrate → app, api
cloudflare-r2 → app        cloudflare-kv → web

Checked locally: terraform validate on all four roots; tests/db (9 tests on PGlite: manifest checksums, the offline plan, RLS on every table, the guard); orun plan and orun catalog validate.


Generated by Claude Code

Four Terraform roots, each one per environment and each publishing what the
Workers render their config from: infra/terraform/supabase (a Supabase
project; its ref, password and URL as Orun secrets) and
infra/terraform/cloudflare-hyperdrive (a Hyperdrive config over its Postgres,
WIRING_CLOUDFLARE_HYPERDRIVE), as saas-starter has them;
infra/terraform/cloudflare-r2 (the storage bucket, WIRING_CLOUDFLARE_R2) from
blob-starter; infra/terraform/cloudflare-kv (the rate-limit namespace,
WIRING_CLOUDFLARE_KV) from kv-redis-starter. All four pass terraform validate.

The schema replaces `prisma migrate`: packages/db (@app/db) holds the
checksummed migrations and saas-starter's runner, which infra/db-migrate runs
through Supabase's Management API — 010_pages is upstream's one Prisma model
under Prisma's own names, 020_row_level_security closes public to Supabase's
Data API (anon, authenticated) while the apps, which own the table, keep
everything. tests/db runs them on PGlite: the manifest, the offline plan,
RLS on every table and the guard that refuses to lock the apps out.

The Workers now wait for what they bind, enforced on a merge and advisory on
a pull request: app on Hyperdrive, R2 and the migrations; api on Hyperdrive
and the migrations; web on KV. `orun plan` on the push to main orders each
environment supabase -> cloudflare-hyperdrive -> db-migrate -> app/api, with
cloudflare-r2 -> app and cloudflare-kv -> web beside them.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019PcpNVpFBcbeiX3EHdXfmn
@ruehowl
ruehowl merged commit 28385a7 into main Oct 28, 2026
2 checks passed
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.

2 participants