Schema: move epoch BIGINT timestamps to timestamptz, tighten identity/status columns #39

Open
opened 2026-10-09 12:42:38 +00:00 by niklas · 0 comments
Owner

Deferred from the Oct 2026 review. Best done before the first release, while 001_schema.sql is the only migration.

  • All timestamps are BIGINT Unix seconds (the old 001 header said "worth revisiting"). Move to timestamptz; this touches most queries (time.Unix(...) scans, nowEpoch, to_timestamp(received_at) in stats).
  • Identity columns are GENERATED BY DEFAULT (kept only for the SQLite import that no longer exists); use ALWAYS.
  • schedule_entries.date is a TEXT UTC day, so there is no per-team timezone.
  • incident_events.type and escalation_targets.kind are free text / partly constrained: add CHECKs.
  • incidents.status is redundant with resolved_at / snoozed_until / archived_at.
  • Write-only columns never read by any query: users.invited_via, sessions.user_agent, user_identities.last_login_at (use them, e.g. a session list, or drop).

Mirror any JSON shape change in terdut-tui/internal/api/types.go and terdut-operator/internal/tdclient.

Deferred from the Oct 2026 review. Best done before the first release, while `001_schema.sql` is the only migration. - All timestamps are `BIGINT` Unix seconds (the old 001 header said "worth revisiting"). Move to `timestamptz`; this touches most queries (`time.Unix(...)` scans, `nowEpoch`, `to_timestamp(received_at)` in stats). - Identity columns are `GENERATED BY DEFAULT` (kept only for the SQLite import that no longer exists); use `ALWAYS`. - `schedule_entries.date` is a TEXT UTC day, so there is no per-team timezone. - `incident_events.type` and `escalation_targets.kind` are free text / partly constrained: add CHECKs. - `incidents.status` is redundant with `resolved_at` / `snoozed_until` / `archived_at`. - Write-only columns never read by any query: `users.invited_via`, `sessions.user_agent`, `user_identities.last_login_at` (use them, e.g. a session list, or drop). Mirror any JSON shape change in `terdut-tui/internal/api/types.go` and `terdut-operator/internal/tdclient`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: niklas/terdut-server#39