+++ title = "Define Cloudflare D1 database resource and document binding name for the Worker" priority = 7 status = "todo" ticket_type = "task" dependencies = ["25c413", "2d1371", "5c0c64"] +++ Infrastructure is managed with OpenTofu using the Cloudflare provider. Configuration lives in `infra/`. Resources include a Cloudflare Worker (API), Cloudflare D1 database (bound to the worker), and a Cloudflare Pages project (UI frontend). Cloudflare D1 is the production SQLite-compatible database. It must be provisioned before the Worker can bind to it. Define the Cloudflare D1 database resource in `infra/d1.tf`: 1. `cloudflare_d1_database` resource for the `quotesdb` database 2. Output the D1 database ID so it can be referenced in the Worker binding 3. Document the binding name (e.g. `DB`) that the Worker expects — this must match the workers-rs binding name in the API code Every block must have a comment. - Resolve TRIAGE ticket 5c0c64 (D1 migrations in OpenTofu) for how to apply the schema after provisioning. - Document the D1 database ID output — needed for the Worker binding (ticket 07cafb). Run from the `infra/` directory: ```sh tofu validate tofu plan ``` `feat(quotesdb): define Cloudflare D1 database resource in OpenTofu`