Rebasely Beta: data may be purged

examples/storefront Public

0001 One D1 database for the shop's data

Decision 0001 Accepted

Owner
justin
Reviewed
2026-10-01

Context

The 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.

Decision

All 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 Running and writing tests), 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.