--- pushes

CREATE TABLE push_tokens (
  id         BIGINT IDENTITY (1, 1) 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(4000)  NOT NULL,
  active     BIT            NOT NULL DEFAULT 0,
  created_at DATETIMEOFFSET NOT NULL DEFAULT sysdatetimeoffset(),
  updated_at DATETIMEOFFSET NOT NULL DEFAULT sysdatetimeoffset()
);

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);
