Repository navigation
BA2: D1, KV and R2 from Terraform, the schema through db-migrate - #3
Merged
Merged
Conversation
The three bindings the example asked its owner to create by hand, as Terraform roots Orun applies per environment: turso-starter's cloudflare-d1, kv-redis-starter's cloudflare-kv and blob-starter's cloudflare-r2 (as ai-emoji-generator combined them), each lease-publishing the wiring document the Worker's config renders from. infra/db-migrate runs packages/db's runner over D1's REST API after the database's apply — better-auth's tables and the generated auth secret — so the auth app never meets a database without its schema. apps/web now waits on all four on a merge to main (enforced; advisory on a pull request) and renders stage and prod from their wiring documents, dev from the fixture; the product's own plan orders the roots, then the migrations, then the Worker. Every root passes terraform validate. This also restores the packages/db, tests/db and tests/web component manifests in full: BA1 landed them cut short by a faulty edit, unnoticed because CI plans nothing while the workspace is the placeholder. 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 example has its owner create the three bindings by hand. This PR makes them Terraform roots that Orun applies per environment:
infra/terraform/cloudflare-d1(turso-starter's),cloudflare-kv(kv-redis-starter's) andcloudflare-r2(blob-starter's), as ai-emoji-generator combined them. Each lease-publishes the wiring document the Worker's config renders from (WIRING_CLOUDFLARE_{D1,KV,R2}).infra/db-migraterunspackages/db's runner over D1's REST API after the database's apply. That creates better-auth's tables and the generated auth secret.apps/webnow waits on all four on a merge to main (enforced; advisory on a pull request). Stage and prod render from their wiring documents; dev renders from the fixture.packages/db,tests/dbandtests/webcomponent manifests in full. BA1 landed them cut short by a faulty edit of mine. Nothing noticed, because CI plans nothing while the workspace is the placeholder.Checks run locally
terraform validatepasses on all three roots.orun plan --trigger github-push-main --env stage, run against a stand-in workspace, gives the expected order:cloudflare-d1,cloudflare-kvandcloudflare-r2first;db-migrate(after d1);web(after all four).pnpm test: tests/web 22, tests/db 14. The committedwrangler.jsoncis unchanged by a re-render.Generated by Claude Code