fix(database): preserve playlist phantoms across a stale audio_files retire #245

Merged
yonlu merged 2 commits from fix/183-phantom-across-retire into main 2026-09-09 13:54:37 +00:00
Owner
commit issue
a3b5b437 fix(database): preserve playlist phantoms across a stale audio_files retire #183
68e7edb8 feat(database): listening-events log with skip counters — (plan 021 phase 2; #185 stays open)

Verification

  • go build ./...
  • go test ./backend/database/... ./backend/library/... ./backend/queue/... ./backend/datamap/...
  • ./scripts/codegen-check.sh

The second commit is plan 021 phase 2 only: the schema the classifier
records into (listening_events, skip_count/last_skipped), plus the
dead queue.source_playlist_id drop and the stale migration-chain
references cleaned out of the download/tagging schemas. The classifier
and its wiring are phases 1 and 3 and are not in this PR.

Closes #183

| commit | issue | |---|---| | `a3b5b437` fix(database): preserve playlist phantoms across a stale audio_files retire | #183 | | `68e7edb8` feat(database): listening-events log with skip counters | — (plan 021 phase 2; #185 stays open) | ## Verification - `go build ./...` - `go test ./backend/database/... ./backend/library/... ./backend/queue/... ./backend/datamap/...` - `./scripts/codegen-check.sh` The second commit is plan 021 phase 2 only: the schema the classifier records into (`listening_events`, `skip_count`/`last_skipped`), plus the dead `queue.source_playlist_id` drop and the stale migration-chain references cleaned out of the download/tagging schemas. The classifier and its wiring are phases 1 and 3 and are not in this PR. Closes #183
yonlu added 2 commits 2026-09-09 13:24:48 +00:00
Retiring a stale audio_files dropped every playlist entry to an empty
row: ON DELETE SET NULL ran before the phantom_* columns were filled,
whereas the manual rescan path populates them first. Run the same
phantom population inside the retire transaction, before the drop, only
when audio_files is among the tables going, so
ResolvePhantomTracksAfterScan can re-link the entries.

Closes #183
feat(database): listening-events log with skip counters
CI / check (push) Skipped
CI / e2e (push) Skipped
CI / check (pull_request) Successful in 5m23s
CI / e2e (pull_request) Successful in 11m9s
68e7edb8c9
Replace play_history with listening_events — one row per track exit,
kind (complete/play/skip) plus raw position/duration — and add
skip_count/last_skipped to audio_files beside play_count/last_played.
The classifier that writes these lands later (plan 021); this is the
schema it records into.

Also drop the dead queue.source_playlist_id column and remove the stale
references to the squashed migration chain in download_*.sql and
tagging_items.sql, declaring the missing download-request indexes inline.
yonlu merged commit 6aeac42a46 into main 2026-09-09 13:54:37 +00:00
Sign in to join this conversation.