fix(server): delete analytics_events rows on account deletion #142
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Review finding L4 (2026-07-06).
analytics_events.user_idhas no FK/cascade (004_analytics.sql), so a deleted account's analytics rows persist forever while every other user table cascades. Privacy nit. Fix options: add aDELETE FROM analytics_events WHERE user_id = ?todelete_account, or (preferred, keeps aggregate stats) anonymise:UPDATE analytics_events SET user_id = NULL WHERE user_id = ?. Migrations are append-only, so don't retrofit an FK — handle it in the handler.🤖 Generated with Claude Code
Investigated before fixing: nothing in the workspace reads or writes analytics_events — no server route ingests it and the client ships events to the external Matomo instance (analytics.aleshym.co) via MatomoClient. The table from migration 004 is dead scaffolding with zero rows in practice, so there is no user data to clean up on account deletion and the handler fix would touch a table that is never written. Remaining decision (schema change, needs owner sign-off per CLAUDE.md §8): add a migration 006 dropping the unused table, or leave it dormant. Closing as no-user-data-at-risk; reopen if analytics ingest is ever wired server-side.