
CREATE TABLE public.custom_ledgers (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  name TEXT NOT NULL,
  association_id UUID REFERENCES public.associations(id) ON DELETE SET NULL,
  owner_id UUID REFERENCES public.owners(id) ON DELETE SET NULL,
  rows JSONB DEFAULT '[]'::jsonb,
  settings JSONB DEFAULT '{}'::jsonb,
  created_by UUID,
  created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
  updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);

ALTER TABLE public.custom_ledgers ENABLE ROW LEVEL SECURITY;

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