Files
quicproquo/crates/quicproquo-server/migrations/002_add_seq.sql
Chris Nennemann 853ca4fec0 chore: rename project quicnprotochat -> quicproquo (binaries: qpq)
Rename the entire workspace:
- Crate packages: quicnprotochat-{core,proto,server,client,gui,p2p,mobile} -> quicproquo-*
- Binary names: quicnprotochat -> qpq, quicnprotochat-server -> qpq-server,
  quicnprotochat-gui -> qpq-gui
- Default files: *-state.bin -> qpq-state.bin, *-server.toml -> qpq-server.toml,
  *.db -> qpq.db
- Environment variable prefix: QUICNPROTOCHAT_* -> QPQ_*
- App identifier: chat.quicnproto.gui -> chat.quicproquo.gui
- Proto package: quicnprotochat.bench -> quicproquo.bench
- All documentation, Docker, CI, and script references updated

HKDF domain-separation strings and P2P ALPN remain unchanged for
backward compatibility with existing encrypted state and wire protocol.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 20:11:51 +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);