Skip to content

Commit ab6bd97

Browse files
JW-90124JW-90124claude
authored
fix: skip stale signal_triage rows instead of re-inserting during snapshot restore (#33)
When a snapshot row is older than the existing database row, the previous logic fell through to the insert branch and violated the signal_triage primary key. Stale rows are now skipped. Co-authored-by: JW-90124 <jww2708@gmail.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent f943095 commit ab6bd97

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/pipeline/snapshot.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -871,8 +871,10 @@ async function restoreSnapshot(
871871
details_json: JSON.stringify(value.details ?? {}),
872872
updated_at: optionalString(value.updatedAt) ?? requiredString(value, "createdAt"),
873873
};
874-
if (existing && compareTimestamp(row.updated_at, existing.updated_at) >= 0) {
875-
await db.updateTable("signal_triage").set(row).where("signal_id", "=", signalId).execute();
874+
if (existing) {
875+
if (compareTimestamp(row.updated_at, existing.updated_at) >= 0) {
876+
await db.updateTable("signal_triage").set(row).where("signal_id", "=", signalId).execute();
877+
}
876878
} else {
877879
await db
878880
.insertInto("signal_triage")

0 commit comments

Comments
 (0)