-- Internal lot map for the RV/Boat Lots page: per-association pin layout
-- (config holds { pins, zoom, locked_view }); pins may link a directory unit.
create table if not exists public.rv_boat_lot_maps (
  association_id uuid primary key references public.associations(id) on delete cascade,
  config jsonb not null default '{}'::jsonb,
  updated_at timestamptz default now()
);

alter table public.rv_boat_lot_maps enable row level security;

drop policy if exists "Staff manage rv boat lot maps" on public.rv_boat_lot_maps;
create policy "Staff manage rv boat lot maps"
  on public.rv_boat_lot_maps for all
  to authenticated
  using (has_role(auth.uid(), 'admin'::app_role) or has_role(auth.uid(), 'manager'::app_role) or has_role(auth.uid(), 'association_management'::app_role))
  with check (has_role(auth.uid(), 'admin'::app_role) or has_role(auth.uid(), 'manager'::app_role) or has_role(auth.uid(), 'association_management'::app_role));
