Order history log captures all state changes with timestamps
Why it matters
Without a persistent order history log, you cannot answer the questions that matter most during a dispute or refund: When did the order ship? Who changed the status? Was the cancellation before or after fulfillment? The only surviving evidence is the current status field and a single updatedAt timestamp that gets overwritten on every subsequent change. CWE-778 (Insufficient Logging) and GDPR Art. 5(1)(f) both require that processing activities are traceable and reconstructable. An updatedAt column proves nothing — it's a cursor, not a log.
Severity rationale
High because missing history makes it impossible to reconstruct the order timeline during disputes, refund requests, or compliance audits, and the gap can never be backfilled after the fact.
Remediation
Create an order_history table and write to it atomically inside the same database transaction as every status update. Use db.$transaction to guarantee both writes succeed or neither does.
// prisma/schema.prisma addition:
// model OrderHistory {
// id String @id @default(cuid())
// orderId String
// fromStatus String?
// toStatus String
// actorId String?
// note String?
// createdAt DateTime @default(now())
// order Order @relation(fields: [orderId], references: [id])
// }
// lib/orders/state-machine.ts
await db.$transaction([
db.orders.update({ where: { id: orderId }, data: { status: newStatus } }),
db.orderHistory.create({
data: { orderId, fromStatus: order.status, toStatus: newStatus, actorId, note },
}),
])
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Order Management Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-778 — Insufficient Logging
- iso-25010:2011 · functional-correctness — Functional Correctness
- gdpr · Art. 5(1)(f) — Integrity and confidentiality of personal data processing records
Taxons
History
- 2026-04-18·v1.0.0·Initial import from ecommerce-order-management·automated