Files
Christian Nennemann a710037dde chore: rename quicproquo → quicprochat in Rust workspace
Rename all crate directories, package names, binary names, proto
package/module paths, ALPN strings, env var prefixes, config filenames,
mDNS service names, and plugin ABI symbols from quicproquo/qpq to
quicprochat/qpc.
2026-03-21 19:14:06 +01:00

22 lines
888 B
SQL

-- Migration 002: add per-inbox delivery sequence numbers.
--
-- Adds a `seq` column to the deliveries table and a separate counter table
-- that tracks the next sequence number per (recipient_key, channel_id) inbox.
-- The counter is atomically incremented on each enqueue via an UPSERT so
-- sequence numbers are gapless even under concurrent inserts.
--
-- Requires SQLite >= 3.35 (RETURNING clause support; available on Ubuntu 22.04+).
ALTER TABLE deliveries ADD COLUMN seq INTEGER NOT NULL DEFAULT 0;
CREATE TABLE IF NOT EXISTS delivery_seq_counters (
recipient_key BLOB NOT NULL,
channel_id BLOB NOT NULL,
next_seq INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (recipient_key, channel_id)
);
-- Index lets ORDER BY seq queries use an index scan instead of a sort.
CREATE INDEX IF NOT EXISTS idx_del_seq
ON deliveries (recipient_key, channel_id, seq);