-- Allow moderators to delete test data from version tables
-- This enables test data cleanup operations to work properly

-- Park versions
CREATE POLICY "Moderators can delete test park versions"
ON park_versions
FOR DELETE
TO authenticated
USING (
  is_test_data = true 
  AND is_moderator(auth.uid())
);

-- Ride versions  
CREATE POLICY "Moderators can delete test ride versions"
ON ride_versions
FOR DELETE
TO authenticated
USING (
  is_test_data = true 
  AND is_moderator(auth.uid())
);

-- Company versions
CREATE POLICY "Moderators can delete test company versions"
ON company_versions
FOR DELETE
TO authenticated
USING (
  is_test_data = true 
  AND is_moderator(auth.uid())
);

-- Ride model versions
CREATE POLICY "Moderators can delete test ride model versions"
ON ride_model_versions
FOR DELETE
TO authenticated
USING (
  is_test_data = true 
  AND is_moderator(auth.uid())
);