2.9 KiB
| title | status | type | priority | created_at | updated_at |
|---|---|---|---|---|---|
| [TRIAGE] D1 migrations in OpenTofu — null_resource local-exec vs separate wrangler step vs manual | completed | task | critical | 2026-03-10T23:32:07Z | 2026-03-10T23:32:07Z |
-
null_resource local-exec rejected:
null_resourceprovisioners are an OpenTofu anti-pattern. They don't re-run unless tainted, aren't tracked in state, require wrangler installed on the CI runner attofu applytime, and break idempotency. The convenience of a single command is not worth the coupling. -
API startup migration rejected: Cloudflare Workers spin up per-request via V8 isolates. There is no persistent startup phase. Running DDL (
CREATE TABLE IF NOT EXISTS) before every request adds latency and is fragile. The Workers fetch handler (D1Repository, wasm32 path) does NOT run migrations. This is only viable for the native/local dev path (rusqlite), whereNativeRepository::run_migrations()is called once atmain()startup. -
Separate wrangler step chosen: This is Cloudflare's canonical approach. The schema SQL lives at
infra/schema.sql(ticket bb1514). Aftertofu apply, run once:wrangler d1 execute quotesdb --file infra/schema.sql --remoteIdempotent with
CREATE TABLE IF NOT EXISTS. Integrates cleanly into CI/CD as a post-apply step. Keeps OpenTofu focused on infrastructure, not data.
Note: TRIAGE 580e66 asks the same question from the Workers runtime angle and arrives at the same answer. Both are now resolved together.
- Ticket d0da0b updated: constraint clarified (wrangler step, no null_resource). - Ticket a5049d updated: migration strategy constraint updated (580e66 also resolved). - Ticket 75489a updated: dependency on bb1514 added; goal updated to reference infra/schema.sql. - Ticket 580e66 resolved as co-decided. - New ticket bb1514 created: full implementation plan for `infra/schema.sql`. `chore(quotesdb): resolve triage — d1-migrations-in-opentofu-nullresource-localexec-vs-separate`