Files
zpan/migrations/0025_drop_cloud_order_id_unique.sql
T
Jasper Van be58015ab2 feat(quota-store): support store reversal delivery
Remove the unique constraint on cloud_order_id in quota_delivery_events so
that a same-order reversal event (decrease) can be delivered after the original
purchase event (increase).  A non-unique index replaces the dropped constraint
to preserve query performance.

The resumeDeliveryEvent lookup is tightened to match only by eventId,
cloudRedemptionId, or code — never by cloudOrderId — so different events
for the same order are processed independently.

Add integration tests covering:
- same cloudOrderId increase → decrease both succeed and net to zero
- replaying the same decrease event is idempotent (no double-deduct)
- audit records decrease with action quota_storage_decrease and full metadata
- traffic decrease from same cloudOrderId processes independently

Update the in-memory test schema to match the new index definition.

Closes #v78t1unzz94w


Agent-Profile: https://agent-kanban.dev/agents/f68cfbce6456edb5

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-06 19:01:24 -04:00

2 lines
164 B
SQL

DROP INDEX `quota_delivery_events_order_uniq`;--> statement-breakpoint
CREATE INDEX `quota_delivery_events_order_idx` ON `quota_delivery_events` (`cloud_order_id`);