-- Runs after 20250702_trip_logs_modal.sql to finalize handler names

-- Delete duplicate Trip Logs rows keeping the lowest id
DELETE FROM ui_modals
WHERE name = 'Trip Logs'
  AND id NOT IN (
    SELECT MIN(id) FROM ui_modals WHERE name = 'Trip Logs'
  );

-- Update remaining Trip Logs modal config
UPDATE ui_modals
SET config =
  REPLACE(
    REPLACE(config::text, 'openTripMapView', 'openMapView'),
    'openTripDetail', 'openDetail'
  )::jsonb
WHERE name = 'Trip Logs';
