mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Signed-off-by: Will Pfleger <pfleger.will@gmail.com> Co-authored-by: npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@sprout-oss.stage.blox.sqprod.co>
18 lines
876 B
SQL
18 lines
876 B
SQL
-- Add NIP-ER event-reminder columns and due-delivery index to the events table.
|
|
--
|
|
-- `not_before` is the reminder's scheduled delivery time (Unix seconds);
|
|
-- `delivered_at` records when the scheduler published it. Both are nullable —
|
|
-- non-reminder events leave them NULL. The partial index covers only
|
|
-- undelivered, live reminders so the scheduler's due-query stays cheap.
|
|
--
|
|
-- `events` is partitioned by RANGE (created_at); ALTER TABLE on the parent
|
|
-- cascades the columns to every partition, and CREATE INDEX on the parent
|
|
-- builds a partitioned index that propagates to each partition.
|
|
--
|
|
-- Managed by sqlx migrations.
|
|
|
|
ALTER TABLE events ADD COLUMN not_before BIGINT;
|
|
ALTER TABLE events ADD COLUMN delivered_at BIGINT;
|
|
CREATE INDEX idx_events_not_before ON events (not_before)
|
|
WHERE not_before IS NOT NULL AND deleted_at IS NULL AND delivered_at IS NULL;
|