diff --git a/src/integrations/supabase/types.ts b/src/integrations/supabase/types.ts index c772f27..c8784fe 100644 --- a/src/integrations/supabase/types.ts +++ b/src/integrations/supabase/types.ts @@ -2037,6 +2037,7 @@ export type Database = { incoming_emails: { Row: { attachment_count: number + attachments: Json body_html: string | null body_text: string | null case_id: string | null @@ -2065,6 +2066,7 @@ export type Database = { } Insert: { attachment_count?: number + attachments?: Json body_html?: string | null body_text?: string | null case_id?: string | null @@ -2093,6 +2095,7 @@ export type Database = { } Update: { attachment_count?: number + attachments?: Json body_html?: string | null body_text?: string | null case_id?: string | null diff --git a/supabase/migrations/20260424033216_acdc534c-c381-4445-9bf4-99cfe5f1c8a3.sql b/supabase/migrations/20260424033216_acdc534c-c381-4445-9bf4-99cfe5f1c8a3.sql new file mode 100644 index 0000000..70a0fe9 --- /dev/null +++ b/supabase/migrations/20260424033216_acdc534c-c381-4445-9bf4-99cfe5f1c8a3.sql @@ -0,0 +1,21 @@ +ALTER TABLE public.incoming_emails + ADD COLUMN IF NOT EXISTS attachments jsonb NOT NULL DEFAULT '[]'::jsonb; + +INSERT INTO storage.buckets (id, name, public) +VALUES ('email-attachments', 'email-attachments', false) +ON CONFLICT (id) DO NOTHING; + +CREATE POLICY "email_attachments_select_auth" + ON storage.objects FOR SELECT + TO authenticated + USING (bucket_id = 'email-attachments'); + +CREATE POLICY "email_attachments_insert_auth" + ON storage.objects FOR INSERT + TO authenticated + WITH CHECK (bucket_id = 'email-attachments'); + +CREATE POLICY "email_attachments_delete_admin" + ON storage.objects FOR DELETE + TO authenticated + USING (bucket_id = 'email-attachments' AND public.is_admin(auth.uid())); \ No newline at end of file