Repository navigation
AT2: Supabase and Hyperdrive from Terraform, the schema through db-migrate - #3
Merged
Merged
Conversation
…grate infra/terraform/supabase (supabase-starter's root) creates each environment's Supabase project with Auth pointed at the Worker and sign-up signing straight in, and publishes the database credentials, the wiring document the build and the Worker read (URL and publishable key) and the service-role key, which only the Worker's deploy reads, to store as a Worker secret for the admin functions. infra/terraform/cloudflare-hyperdrive puts a Hyperdrive config, caching off, in front of each project's Postgres. packages/db (@saas/db) carries upstream's 30 supabase/migrations in their order — the history supabase db push applies, which a comparison on a Supabase-shaped Postgres showed to be the schema upstream's declarative files describe, less one grant they still give — then its seed, then the port's outbox: cleanup_note_attachments() queues a note's old and new record, and the Worker's Cron Trigger drains the queue through the Storage API with upstream's own getPathsToDelete, where upstream's trigger called the edge function through pg_net. Three upstream files carry a marked edit (pgjwt, absent on Postgres 17, is not created; http and pg_net are created where installed). infra/db-migrate applies them through the Management API before the Worker deploys. tests/db applies every migration with db-migrate's runner to a Supabase-shaped PGlite, twice, and checks sign-up, the Data API's roles, the bucket and its policies, the seed and the outbox; tests/web covers the drain. tooling/catalog generates each component's docs from its manifests. 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.
This PR adds the data plane behind the CRM's Worker.
infra/terraform/supabase(supabase-starter's root) creates one Supabase project per environment.WIRING_SUPABASE(the URL and publishable key).SUPABASE_SERVICE_ROLE_KEY. Only the Worker's deploy reads it, and stores it as a Worker secret for the admin functions.infra/terraform/cloudflare-hyperdriveputs a Hyperdrive config in front of each project's Postgres, with caching off.packages/db(@saas/db) holds 33 checksummed migrations, applied through the Management API byinfra/db-migratebefore the Worker deploys:supabase/migrations, in order. This is whatsupabase db pushapplies. I compared it with upstream's declarativesupabase/schemason a Supabase-shaped Postgres 16. The two match except for one column's position and one grant the declarative files still give (get_user_id_by_emailtoanonandauthenticated), which the history revokes. So the history is what ships.pgjwtis not created (it's unused, and absent on Postgres 17).httpandpg_netare created where they are installed.--include-seed.cleanup_note_attachments()now queues the note's old and new record. The Worker's Cron Trigger (every ten minutes) drains the queue through the Storage API, using upstream's owngetPathsToDelete. Upstream's trigger called the edge function throughpg_netinstead, and the database has no address for the Worker.apps/webnow deploys aftersupabase,cloudflare-hyperdriveanddb-migrate, and renders its config from their wiring documents.tests/dbapplies every migration with db-migrate's runner to a Supabase-shaped PGlite, twice; the second run applies nothing. It then checks:auth.usersemails are kept from those roles;tooling/cataloggenerates each component's docs from its manifests.Checked locally:
terraform validatepasses for both roots.postgreson a real Postgres 16.pnpm typecheck,lint,testandbuildare green: 437 web tests plus upstream's skip, and 16 DB tests.orun plangives 7 components × 3 envs → 14 jobs.Generated by Claude Code