Когда использовать
Build a small durable SQLite backend with explicit invariants.
Решения для реализации
- Use uniqueness, foreign-key and nonnegative-stock constraints.
- Enable foreign keys per connection and set a busy timeout.
- Use BEGIN IMMEDIATE for inventory read-modify-write and roll back failures.
- Version schema changes and verify them against disposable databases.
Как проверить результат
- Values are parameterized.
- Restart preserves records.
- Failed checkout cannot partially decrement stock.