mirror of
https://github.com/block/buzz.git
synced 2026-10-27 04:30:52 +00:00
15 lines
675 B
SQL
15 lines
675 B
SQL
CREATE TABLE push_gateway_delegations (
|
|
id UUID PRIMARY KEY,
|
|
installation_id UUID NOT NULL REFERENCES push_gateway_installations(id),
|
|
relay_pubkey BYTEA NOT NULL CHECK (length(relay_pubkey) = 32),
|
|
endpoint_epoch BIGINT NOT NULL CHECK (endpoint_epoch > 0),
|
|
generation BIGINT NOT NULL CHECK (generation > 0),
|
|
not_before TIMESTAMPTZ NOT NULL,
|
|
expires_at TIMESTAMPTZ NOT NULL,
|
|
revoked_at TIMESTAMPTZ,
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
UNIQUE (installation_id, relay_pubkey),
|
|
CHECK (not_before < expires_at)
|
|
);
|
|
CREATE INDEX push_gateway_delegations_expiry ON push_gateway_delegations (expires_at) WHERE revoked_at IS NULL;
|