-- ============================================================
-- HeavyHaul Agent — fields for the 2026-09-03 feedback round.
--
-- 1. Routes per permit (Task 6): the backend later decides whether a state's
--    route is express or extended and delivers 1..N map links (multi-part).
-- 2. Permit-scoped chat (Task 7): a question can target one exact permit
--    (disambiguates e.g. six Montana permits on one trip).
-- 3. Synchron request notifications (Task 14): who the requester chose to
--    inform (emails are sent by the backend later; the choice is stored now).
-- 4. Broker permit policy (Task 15): the broker's decision at trip-request
--    creation — force Synchron purchase or allow the carrier's own permits.
-- ============================================================

alter table public.service_requests
  add column route_type text check (route_type in ('express', 'extended')),
  add column route_links jsonb,
  add column notify jsonb;

alter table public.chat_messages
  add column permit_id uuid references public.permits (id) on delete set null;

alter table public.trips
  add column permit_policy text check (permit_policy in ('synchron_required', 'upload_allowed'));
