fix(subscriptions): atomic UsageRecord metering to prevent quota bypass
- Add @@unique([subscriptionId, metric, periodStart, periodEnd]) constraint to UsageRecord model with corresponding migration - Replace racy findFirst+update/create pattern with Prisma upsert using INSERT ON CONFLICT DO UPDATE SET count = count + delta - Fix CheckQuotaHandler to use period-scoped findUnique instead of unscoped findFirst, preventing stale cross-period reads - Update tests to reflect atomic upsert pattern Closes GOO-4 Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -126,7 +126,10 @@
|
||||
"VILLA": "Villa",
|
||||
"LAND": "Land",
|
||||
"OFFICE": "Office",
|
||||
"SHOPHOUSE": "Shophouse"
|
||||
"SHOPHOUSE": "Shophouse",
|
||||
"ROOM_RENTAL": "Room Rental",
|
||||
"CONDOTEL": "Condotel",
|
||||
"SERVICED_APARTMENT": "Serviced Apartment"
|
||||
},
|
||||
"transactionTypes": {
|
||||
"SALE": "Sale",
|
||||
|
||||
@@ -126,7 +126,10 @@
|
||||
"VILLA": "Biệt thự",
|
||||
"LAND": "Đất nền",
|
||||
"OFFICE": "Văn phòng",
|
||||
"SHOPHOUSE": "Shophouse"
|
||||
"SHOPHOUSE": "Shophouse",
|
||||
"ROOM_RENTAL": "Phòng trọ",
|
||||
"CONDOTEL": "Condotel",
|
||||
"SERVICED_APARTMENT": "Căn hộ dịch vụ"
|
||||
},
|
||||
"transactionTypes": {
|
||||
"SALE": "Bán",
|
||||
|
||||
Reference in New Issue
Block a user