--- pushes

CREATE TABLE push_tokens (
  id         BIGINT PRIMARY KEY,
  uid        VARCHAR(40) NOT NULL,
  channel_id BIGINT      NOT NULL REFERENCES channels (id),
  client_id  BIGINT      NOT NULL REFERENCES clients (id),
  type       VARCHAR(16) NOT NULL,
  token      VARCHAR,
  active     BOOLEAN     NOT NULL DEFAULT FALSE,
  created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
  updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);

CREATE SEQUENCE push_tokens_id_seq;
CREATE UNIQUE INDEX push_tokens_uid_uniq
  ON push_tokens (uid);
CREATE UNIQUE INDEX push_tokens_client_id_uid_uniq
  ON push_tokens (client_id, uid);
