create table public.sequin_events (
  id bigserial primary key,
  seq bigint not null,
  source_database_id uuid not null,
  source_table_oid bigint not null,
  source_table_schema text not null,
  source_table_name text not null,
  record_pk text not null,
  record jsonb not null,
  changes jsonb,
  action text not null,
  transaction_annotations jsonb,
  committed_at timestamp with time zone not null,
  inserted_at timestamp with time zone not null default now()
);

create unique index on public.sequin_events (source_database_id, committed_at, seq, record_pk);
create index on public.sequin_events (seq);
create index on public.sequin_events (source_table_oid);
create index on public.sequin_events (committed_at);

-- important comment to identify this table as a sequin events table
comment on table public.sequin_events is '$sequin-events$';
