Files
seismo-relay/sfm
serversdownandClaude Opus 5.5 ea2dfc21b7 feat(db): events are identified by unit + time + type (#51)
The events table was UNIQUE(serial, timestamp): one event per unit per
second.  A unit records a waveform and a histogram in the same second
legitimately -- 209 times in prod's 2026-09-30 store once histograms
carry Blastware's start -- so the key is now (serial, timestamp,
record_type).  Agreed with Brian 2026-11-03.

- Migration 3 rebuilds the table from its own current definition with
  only the key swapped, in one transaction: every column, row and id is
  kept (Terra-View reads rows by id) and the indexes are recreated.
  Migration 1's check no longer mistakes the new key for a missing one.
- The upsert, the estimate guard and the restamp match on the type too.
  The restamp also re-types a file's own row in place: before v0.33.0 a
  row's type came from the filename, and a re-import under the file's
  own type must not add a second row.
- An untyped event still refreshes the untyped row at its second (a
  UNIQUE key treats NULLs as distinct).
- scripts/repair_unknown_serials.py checks the new key.

No time changes yet: that is the next commit, and they ship together.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ALX2R8pghDaZuti9U7mEE9
2026-11-03 21:29:46 -05:00
..
2026-03-30 23:23:29 -04:00