Rebasely Beta: data may be purged

examples/storefront Public

Markdown · 22 lines · 949 B · at c8458cc

---id: 0001-d1-for-shop-datatype: decisionowner: justinstatus: acceptedreviewed: 2026-10-01---# 0001 One D1 database for the shop's data## ContextThe storefront needs products, carts and, soon, orders. Checkout has to read a cart, take stock and create an order as one step that either happens completely or not at all.## DecisionAll of it lives in one D1 database, `storefront`. Tables are created and changed only by numbered migrations in `migrations/`. Multi-statement writes go through `db.batch()`, which D1 runs as a single transaction.## Consequences- Checkout can take stock and create the order in one batch, and a `CHECK` constraint can refuse the whole batch.- The tests run the same migrations against SQLite (see [[testing]]), so the SQL the tests exercise is the SQL that ships.- One database is one write path. A shop of this size is far from D1's limits; if that changes, carts are the first table to move out.