From bed838c365d87a3c33b98c4bc40c116d9d21401a Mon Sep 17 00:00:00 2001 From: MarekWo Date: Tue, 9 Jun 2026 12:15:44 +0200 Subject: [PATCH] feat(db): add channel_messages.raw_packet column for raw resend Stores the full hex packet snapshot (header+transport_codes+path_len+payload) captured at send time, enabling future "Resend (same packet hash)" feature that lets repeaters deduplicate via Packet::calculatePacketHash while still forwarding to nodes that didn't hear the original. NULL for received and pre-migration rows (resend button stays disabled there). PR #1 of 5; subsequent PRs wire up send-time capture, backend endpoint, echo list merge, and UI. Co-Authored-By: Claude Opus 4.7 --- app/database.py | 6 ++++++ app/schema.sql | 1 + 2 files changed, 7 insertions(+) diff --git a/app/database.py b/app/database.py index 5f0b4ea..88c3c86 100644 --- a/app/database.py +++ b/app/database.py @@ -69,6 +69,12 @@ class Database: conn.execute("ALTER TABLE read_status ADD COLUMN is_favorite INTEGER DEFAULT 0") logger.info("Migration: added read_status.is_favorite column") + # Add raw_packet column to channel_messages (raw resend support) + cm_columns = {r[1] for r in conn.execute("PRAGMA table_info(channel_messages)").fetchall()} + if 'raw_packet' not in cm_columns: + conn.execute("ALTER TABLE channel_messages ADD COLUMN raw_packet TEXT") + logger.info("Migration: added channel_messages.raw_packet column") + @contextmanager def _connect(self): """Yield a connection with auto-commit/rollback.""" diff --git a/app/schema.sql b/app/schema.sql index 8c7e7cc..8cec069 100644 --- a/app/schema.sql +++ b/app/schema.sql @@ -86,6 +86,7 @@ CREATE TABLE IF NOT EXISTS channel_messages ( snr REAL, path_len INTEGER, pkt_payload TEXT, -- for echo matching + raw_packet TEXT, -- full hex packet (header+codes+path_len+payload) for raw resend; NULL for received/legacy rows raw_json TEXT, -- original JSON line created_at TEXT NOT NULL DEFAULT (datetime('now')) );