From 7220c5ca3552849d5d5143d28c037eaa72b4e1b9 Mon Sep 17 00:00:00 2001 From: Diego Artiles Date: Sat, 9 Nov 2024 12:56:44 -0300 Subject: [PATCH] fix(apps/chat-with-pdf): fix migration history --- ...=> 20241109155454_auto-remove-document-file.sql} | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) rename apps/chat-with-pdf/supabase/migrations/{20241103005601_remote_schema.sql => 20241109155454_auto-remove-document-file.sql} (50%) diff --git a/apps/chat-with-pdf/supabase/migrations/20241103005601_remote_schema.sql b/apps/chat-with-pdf/supabase/migrations/20241109155454_auto-remove-document-file.sql similarity index 50% rename from apps/chat-with-pdf/supabase/migrations/20241103005601_remote_schema.sql rename to apps/chat-with-pdf/supabase/migrations/20241109155454_auto-remove-document-file.sql index bede889..09c5d62 100644 --- a/apps/chat-with-pdf/supabase/migrations/20241103005601_remote_schema.sql +++ b/apps/chat-with-pdf/supabase/migrations/20241109155454_auto-remove-document-file.sql @@ -5,15 +5,12 @@ set check_function_bodies = off; CREATE OR REPLACE FUNCTION public.remove_document_file_after_removing_chats() RETURNS trigger LANGUAGE plpgsql -AS $function$ -BEGIN - PERFORM remove_file('documents', OLD.id::text || '.pdf'); - +AS $function$BEGIN + DELETE FROM storage.objects + WHERE bucket_id = 'documents' AND name = OLD.id || '.pdf'; + RETURN OLD; -END; -$function$ +END;$function$ ; -CREATE TRIGGER chat_delete_trigger AFTER DELETE ON public."Chat" FOR EACH ROW EXECUTE FUNCTION remove_document_file_after_removing_chats(); -