+++
title = "Document D1 schema migration workflow — how to apply SQL schema changes to D1 in CI/CD"
priority = 7
status = "todo"
ticket_type = "task"
dependencies = ["25c413", "d0da0b"]
+++
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 uses SQL migrations. Because the Worker runs in the Cloudflare runtime (not a standard server), migrations must be applied via a separate mechanism (e.g. `wrangler d1 execute` or a startup script). This workflow must be documented.
Document the D1 schema migration workflow in `infra/README.md` or `docs/MIGRATIONS.md`:
1. How to apply the initial schema SQL to D1 (`wrangler d1 execute --file schema.sql`)
2. How to apply incremental migrations
3. How to apply migrations in CI/CD
4. Where the schema SQL file lives (e.g. `infra/schema.sql` or `src/migrations/`)
5. Cross-reference the TRIAGE decision from ticket 5c0c64 (D1 migrations strategy)
- Resolve TRIAGE ticket 5c0c64 before writing this doc — the strategy determines the workflow.
`docs(quotesdb): document D1 schema migration workflow`