-- Optional NiceSharing host mapping schema
--
-- Do not install this for a standard script or iframe embed.
-- Use it only when a host application needs to associate one of its own
-- records with a thread stored and managed by NiceSharing.

create table if not exists public.nicesharing_thread_links (
  local_type text not null,
  local_id text not null,
  community_slug text not null,
  thread_id text not null,
  created_at timestamptz not null default now(),
  primary key (local_type, local_id, thread_id)
);

create index if not exists nicesharing_thread_links_thread_id_idx
  on public.nicesharing_thread_links (thread_id);

comment on table public.nicesharing_thread_links is
  'Optional mapping between host-owned records and NiceSharing-owned threads.';
