Repository navigation
NF2: the data plane from Terraform, the schema through db-migrate - #3
Merged
Merged
Conversation
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
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.
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 migratereplaced bypackages/db(@app/db: checksummed migrations and saas-starter's Management-API runner) applied byinfra/db-migrate:010_pages— upstream's one Prisma model, the stubPage, under Prisma's own table and key names.020_row_level_security— RLS with no policies on every table inpublic: 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):
appwaits on Hyperdrive, R2 and the migrations;apion Hyperdrive and the migrations;webon KV.orun plan(push to main, stage):Checked locally:
terraform validateon all four roots;tests/db(9 tests on PGlite: manifest checksums, the offline plan, RLS on every table, the guard);orun planandorun catalog validate.Generated by Claude Code