--- inbox-events


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

CREATE SEQUENCE inbox_events_id_seq;

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