mirror of
https://github.com/block/buzz.git
synced 2026-10-27 04:30:52 +00:00
20 lines
829 B
SQL
20 lines
829 B
SQL
-- ── Delivery log (partitioned by month on delivered_at) ──────────────────────
|
|
-- Conformance: subscription delivery audit. community_id carried for tenant
|
|
-- attribution; child of subscriptions.
|
|
|
|
CREATE TABLE delivery_log (
|
|
community_id UUID NOT NULL REFERENCES communities(id),
|
|
id BIGINT GENERATED ALWAYS AS IDENTITY,
|
|
subscription_id VARCHAR(255),
|
|
event_id BYTEA,
|
|
method delivery_method,
|
|
delivered_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
success BOOLEAN,
|
|
http_status INT,
|
|
error_message TEXT,
|
|
attempt_number INT DEFAULT 1,
|
|
PRIMARY KEY (delivered_at, id)
|
|
) PARTITION BY RANGE (delivered_at);
|
|
|
|
CREATE INDEX idx_delivery_log_community_sub ON delivery_log (community_id, subscription_id);
|