Audit and update all foreign key relations in schema.prisma with appropriate cascade/restrict/set-null strategies to prevent orphaned records and FK constraint violations on parent deletion. Changes (RESTRICT → CASCADE): - Agent.userId, Listing.propertyId, Transaction.listingId - Inquiry.listingId, Inquiry.userId, Lead.agentId - Subscription.userId, UsageRecord.subscriptionId - Valuation.propertyId, Review.userId Confirmed correct (no change needed): - Listing.agentId (SetNull), Listing.sellerId (Restrict) - Transaction.buyerId (Restrict), Payment.userId (Restrict) - Payment.transactionId (SetNull), Subscription.planId (Restrict) - PropertyMedia, SavedSearch, RefreshToken, OAuthAccount (CASCADE) Migration: 20260411000000_add_cascade_delete_strategies Co-Authored-By: Paperclip <noreply@paperclip.ing>
16 KiB
16 KiB