feat(db): add missing FK indexes on Listing, Payment, Subscription

- Add @@index([sellerId]) and @@index([propertyId]) to Listing model
- Add @@index([transactionId]) to Payment model
- Add @@index([planId]) to Subscription model
- Prevents full table scans on frequently-queried foreign keys

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Ho Ngoc Hai
2026-04-08 04:02:13 +07:00
parent 402b5b6810
commit f55c8a8788
2 changed files with 125 additions and 0 deletions

View File

@@ -242,6 +242,8 @@ model Listing {
@@index([status])
@@index([transactionType])
@@index([priceVND])
@@index([sellerId])
@@index([propertyId])
@@index([agentId])
@@index([publishedAt])
}
@@ -372,6 +374,7 @@ model Payment {
updatedAt DateTime @updatedAt
@@index([userId])
@@index([transactionId])
@@index([status])
@@index([providerTxId])
}
@@ -423,6 +426,7 @@ model Subscription {
usageRecords UsageRecord[]
@@index([planId])
@@index([status])
}