-- Per-account sequence guards retain order when archive batches interleave accounts. CREATE TABLE IF NOT EXISTS replay_accounts ( source TEXT NOT NULL, author INTEGER NOT NULL REFERENCES identities(id), sequence INTEGER NOT NULL CHECK(sequence > 0), PRIMARY KEY(source, author) ) WITHOUT ROWID; -- Keep index deferral across restarts. A completed source does not defer indexes again. CREATE TABLE IF NOT EXISTS replay_indexes ( singleton INTEGER PRIMARY KEY CHECK(singleton = 1), source TEXT NOT NULL DEFAULT '', deferred INTEGER NOT NULL DEFAULT 0 CHECK(deferred IN (0, 1)) ); INSERT OR IGNORE INTO replay_indexes(singleton) VALUES (1);