Skip to content

Commit aa8c195

Browse files
fybxClaude Sonnet 4.6
andauthored
fix: handle missing columns in older Signal DB schemas (#201)
Some older Signal Desktop databases (e.g. January 2024) are missing columns that the messages query hardcodes: timestamp, serverTimestamp, sourceServiceId, hasAttachments, readStatus, seenStatus, expireTimer. Use PRAGMA table_info(messages) to detect available columns and fall back to NULL AS <colname> for any that are absent. Fixes #171 Co-authored-by: Claude Sonnet 4.6 <claude-sonnet-4-6@anthropic.com>
1 parent 9fe54b8 commit aa8c195

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

sigexport/data.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ def fetch_data(
7575
if not chats or (result[4] in chats_list or result[5] in chats_list):
7676
convos[cid] = []
7777

78+
# Check which columns exist (older DB schemas may be missing some)
79+
c.execute("PRAGMA table_info(messages)")
80+
msg_cols = {row[1] for row in c.fetchall()}
81+
82+
def col(name: str) -> str:
83+
return name if name in msg_cols else f"NULL AS {name}"
84+
7885
# Add date range filtering to the query if provided
7986
where_clause = ""
8087

@@ -98,14 +105,14 @@ def fetch_data(
98105
json,
99106
id,
100107
body,
101-
sourceServiceId,
102-
timestamp,
108+
{col("sourceServiceId")},
109+
{col("timestamp")},
103110
sent_at,
104-
serverTimestamp,
105-
hasAttachments,
106-
readStatus,
107-
seenStatus,
108-
expireTimer
111+
{col("serverTimestamp")},
112+
{col("hasAttachments")},
113+
{col("readStatus")},
114+
{col("seenStatus")},
115+
{col("expireTimer")}
109116
FROM messages
110117
{where_clause}
111118
ORDER BY sent_at

0 commit comments

Comments
 (0)