
CREATE TABLE public.saved_letters (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  association_id UUID REFERENCES public.associations(id) ON DELETE CASCADE,
  name TEXT NOT NULL DEFAULT 'Untitled Letter',
  subject TEXT,
  certified_mail TEXT,
  body_html TEXT,
  recipients JSONB DEFAULT '[]'::jsonb,
  manual_recipients JSONB DEFAULT '[]'::jsonb,
  created_by UUID,
  created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
  updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);

ALTER TABLE public.saved_letters ENABLE ROW LEVEL SECURITY;

CREATE POLICY "Authenticated users can manage saved_letters"
  ON public.saved_letters FOR ALL TO authenticated USING (true) WITH CHECK (true);
