PR writeup

Version numbers that never repeat

Deleting the latest version used to free its number, so the next upload reused it and old ?v=N links pointed at new content. This change makes version numbers permanent.

1 migration

The bug, step by step

Step
Before
After
Upload
v1, v2, v3
v1, v2, v3 · seq = 3
Delete v3
latest = 2
latest = 2 · seq = 3
Upload
new body saved as v3
new body saved as v4
Open old ?v=3 link
shows the wrong page
404, as it should

What changed

A counter that only goes up

A new version_seq column records the highest number ever minted. Deletes never touch it.

Reserve before writing

An upload claims seq + 1 with a compare-and-set before storing the body. The loser of a race gets 409 version_conflict.
-- reserve the next number atomically
UPDATE drops SET version_seq = ?
 WHERE slug = ? AND user_id = ? AND version_seq = ?;

Risk

ConcernAnswer
Gaps in numberingExpected and harmless; clients already read latest_version.
Existing dropsMigration backfills version_seq from latest_version.
Version capNow counts minted numbers, so deleting no longer buys headroom.