01 / DECISION
When this primitive earns a place
Use D1 when relationships and SQL queries are central and the application can own a deliberate schema lifecycle.
02 / ARCHITECTURE
Build the smallest defensible path
Start with constraints and indexes, write forward migrations, bind prepared statements, paginate reads, and define backup and deletion behavior.
- 01Name the contract
Use D1 when relationships and SQL queries are central and the application can own a deliberate schema lifecycle.
- 02Add one primitive
Start with constraints and indexes, write forward migrations, bind prepared statements, paginate reads, and define backup and deletion behavior.
- 03Capture failure evidence
Apply migrations to a disposable database, test constraints and empty results, inspect query plans, and rehearse restore or rebuild.
03 / REPRODUCE
Evidence before confidence
Apply migrations to a disposable database, test constraints and empty results, inspect query plans, and rehearse restore or rebuild.
npx wrangler d1 migrations apply DB --local 04 / BOUNDARY
The production boundary
A database binding does not remove query cost, contention, migration risk, or the need to minimize collected data.
05 / FIRST-PARTY SOURCES
Keep first-party sources authoritative
Product behavior, limits, pricing, and availability can change. Re-check these sources before acting.