Refactor: Fix notification view security

This commit is contained in:
gpt-engineer-app[bot]
2025-11-03 00:30:56 +00:00
parent d44f806afa
commit ecca11a475
5 changed files with 589 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
-- 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;