Security, Performance Optimization and Quality updates
Security Improvements
- Database Security: Fixed function search_path mutable warning
- Added SET search_path to update_route_optimizer_updated_at() function for security
- RLS Policies: Replaced overly permissive policies with proper validation
- changelog_entries: Changed from WITH CHECK (true) to admin role validation
- companies: Added company name validation on INSERT
- industrial_properties: Added lister_id validation on INSERT
- property_inquiries: Added required field validation for anonymous inserts
Performance Optimizations
- RLS Policy Performance: Optimized 67+ RLS policies across 22 tables
- Replaced auth.uid() with (select auth.uid()) to prevent re-evaluation per row
- Auth context now evaluated once per query instead of per row
- Significant performance improvement on tables with large datasets
- Database Indexes: Removed duplicate index on commitment_daily_snapshots
Database Quality
- Supabase Advisor: Resolved all warnings (0 warnings remaining)
- All security warnings fixed
- All performance warnings fixed
- Database now fully optimized and compliant