feat: implement optimistic locking for payment updates

- Add version field to Payment interface and collection schema
- Implement atomic updates using updateMany with version checks
- Add collection hook to auto-increment version for manual admin updates
- Prevent race conditions in concurrent webhook processing
- Index version field for performance

Co-authored-by: Bas <bvdaakster@users.noreply.github.com>
This commit is contained in:
claude[bot]
2025-09-18 17:15:10 +00:00
parent a25111444a
commit 84099196b1
3 changed files with 57 additions and 5 deletions

View File

@@ -48,6 +48,10 @@ export interface Payment {
| boolean
| null;
refunds?: (number | Refund)[] | null;
/**
* Version number for optimistic locking (auto-incremented on updates)
*/
version?: number;
updatedAt: string;
createdAt: string;
}