
CREATE TABLE public.buildium_gl_mappings (
  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,
  association_id UUID NOT NULL REFERENCES public.associations(id) ON DELETE CASCADE,
  charge_type TEXT NOT NULL,
  buildium_gl_account_id TEXT NOT NULL,
  buildium_gl_account_name TEXT,
  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
  updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
  UNIQUE(association_id, charge_type)
);

ALTER TABLE public.buildium_gl_mappings ENABLE ROW LEVEL SECURITY;

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