Files
thrilltrack-explorer/supabase/migrations/20251103002926_c819d1c0-be27-4811-8587-5cbfee979bc5.sql
2025-11-03 00:30:56 +00:00

14 lines
369 B
PL/PgSQL

-- Add helper function for cleanup edge function
CREATE OR REPLACE FUNCTION public.get_orphaned_edit_history()
RETURNS TABLE (id UUID) AS $$
BEGIN
RETURN QUERY
SELECT ieh.id
FROM item_edit_history ieh
WHERE NOT EXISTS (
SELECT 1 FROM submission_items si
WHERE si.id = ieh.item_id
);
END;
$$ LANGUAGE plpgsql SECURITY DEFINER SET search_path = public;