Skip to content

fix(etl): persist track_downloads.created_at instead of defaulting to now() - #515

Open
rickyrombo wants to merge 1 commit into
mainfrom
mjp-etl-track-download-created-at
Open

fix(etl): persist track_downloads.created_at instead of defaulting to now()#515
rickyrombo wants to merge 1 commit into
mainfrom
mjp-etl-track-download-created-at

Conversation

@rickyrombo

Copy link
Copy Markdown
Contributor

What

trackDownload's INSERT omitted created_at, so the column fell back to its
CURRENT_TIMESTAMP default.

Why it matters

On live indexing the default is approximately right. On a genesis replay it
stamps every row with the time of the replay rather than the time of the
download.

Measured against the 2026-08-07 snapshot:

source ETL
2025-03-01 01:55:43 2026-08-12 01:18:23
2025-03-01 01:55:45 2026-08-12 01:18:23
2025-03-01 01:55:52 2026-08-12 01:18:23

All 76,960 migrated rows carried one identical timestamp instead of their
real download times, which span 2024-08 to 2026-08.

The distinct-count signature makes the damage clear:

source:  59,153 distinct (parent,track,user)  ->  76,460 distinct once created_at is included
ETL:     59,153 distinct (parent,track,user)  ->  59,163 distinct once created_at is included

Repeat downloads of the same track by the same user collapsed to a single
timestamp.

Why nothing caught it

Row counts match exactly (76,960 on both sides), and pkg/etl/parity does not
compare created_at for this table — its Columns list is just user_id.

Fix

Write params.BlockTime, which for a migration transaction is the source row's
own created_at.

🤖 Generated with Claude Code

… now()

The INSERT omitted created_at, so the column fell back to its
CURRENT_TIMESTAMP default. On live indexing that is approximately right; on a
genesis replay it stamps every row with the time of the replay.

Measured against the 2026-08-07 snapshot: all 76,960 migrated rows carried the
same created_at (the replay wall-clock) instead of their real download times,
which span 2024-08 to 2026-08. Row counts matched exactly on both sides, so
nothing in the existing checks noticed -- parity does not compare created_at.

Writes params.BlockTime, which for a migration transaction is the source row's
own created_at.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant