Skip to content

A full-featured CRM built with React, shadcn/ui, and Supabase.

Document note attachments cleanup migration intent

Anibal Svarcas7a0e63584cf6
diff --git a/supabase/migrations/20260220154000_note_attachments_webhooks.sql b/supabase/migrations/20260220154000_note_attachments_webhooks.sql
index f726a51d..ce47fc36 100644
--- a/supabase/migrations/20260220154000_note_attachments_webhooks.sql
+++ b/supabase/migrations/20260220154000_note_attachments_webhooks.sql
@@ -1,8 +1,13 @@
+-- Deletes attachment files from storage when note attachments are removed,
+-- either by deleting a note or by updating a note attachments list.
CREATE EXTENSION IF NOT EXISTS pg_net;
DO $migration$
BEGIN
EXECUTE $url_sql$
+ -- SQL triggers cannot read Edge Function env vars directly. Resolve the
+ -- function URL from request context for hosted projects, and keep a local
+ -- fallback for dockerized local development.
CREATE OR REPLACE FUNCTION public.note_attachments_webhook_url()
RETURNS text
LANGUAGE plpgsql