--- inbox-events


CREATE TABLE inbox_events (
  id                      BIGINT IDENTITY (1,1) PRIMARY KEY,
  type                    VARCHAR(64) NOT NULL,
  inbox_id                BIGINT  NOT NULL  REFERENCES inboxes (id),
  inbox_thread_id         BIGINT  NOT NULL REFERENCES inbox_threads (id),
  created_at              DATETIMEOFFSET
);

CREATE INDEX inbox_events_inbox_id_ix
  ON inbox_events (inbox_id, id DESC);
