Repository navigation
Closed
Labels
Description
Goal
Widen the download-counter type in Rust from u32 to u64 and widen the corresponding database columns from INTEGER (32-bit, MySQL) to BIGINT (64-bit), delivered as a versioned sqlx migration so the change is explicit, testable, and tracked as a forward schema change.
Spec
docs/issues/1525-07-align-rust-and-db-types.md
Parent issue
Part of the persistence overhaul EPIC: #1525
Tasks
- Task 1 — Add migration files (
20260409120000_torrust_tracker_widen_download_counters.sqlfor bothsqlite/andmysql/) - Task 2 — Widen
NumberOfDownloadsfromu32→u64, updateSwarmMetadata.downloaded, adddecode_counter/encode_counterhelpers to both drivers, fix all cascade compilation errors - Task 3 — Add tests: MySQL column widening round-trip, SQLite no-op,
encode_countererror on values abovei64::MAX
Acceptance Criteria
packages/tracker-core/migrations/sqlite/20260409120000_torrust_tracker_widen_download_counters.sqlexists and is a comment-only no-op.packages/tracker-core/migrations/mysql/20260409120000_torrust_tracker_widen_download_counters.sqlexists and widenstorrents.completedandtorrent_aggregate_metrics.valuetoBIGINT.NumberOfDownloads = u64inpackages/primitives/src/lib.rs.SwarmMetadata.downloadedusesNumberOfDownloads; bareu32is removed from that field.- Both driver files use explicit
decode_counter/encode_counterhelpers for all counter-column reads and writes. encode_counterreturns an error (not a panic, not silent truncation) for values abovei64::MAX.- A test verifies round-trip of a value larger than
u32::MAXfor each backend. - A test verifies the encode error path for values above
i64::MAX. - No
as u32casts or compiler-suppression attributes introduced by this subissue. cargo test --workspace --all-targetspasses.linter allexits with code0.
References
- EPIC: Overhaul persistence #1525
- Prerequisite: 1525-06: Introduce schema migrations #1719 (1525-06: Introduce schema migrations — must be completed first)
- Next: 1525-08 (Add PostgreSQL driver support)
Activity
docs(issues): rename 1525-07 spec to include GitHub issue number
chore(issues): archive closed issue specs to docs/issues/closed
Merge torrust#1722: feat(tracker-core): widen mysql download counters…