feat(tracker-core): widen mysql download counters to bigint (subissue 1525-07)#1722
Conversation
Rename docs/issues/1525-07-align-rust-and-db-types.md to docs/issues/1721-1525-07-align-rust-and-db-types.md now that GitHub issue torrust#1721 has been opened for this subissue. Update the reference in the EPIC spec (docs/issues/1525-overhaul-persistence.md) accordingly.
There was a problem hiding this comment.
Pull request overview
Adds the next schema migration to widen MySQL download counters to BIGINT (while keeping the Rust domain type NumberOfDownloads = u32) and strengthens driver-level tests and documentation around the new type boundary.
Changes:
- Add migration #4: MySQL widens
torrents.completedandtorrent_aggregate_metrics.valuetoBIGINT; SQLite adds a no-op migration to keep histories aligned. - Extend MySQL/SQLite driver tests to assert migration history count is
4and validate MySQL round-trips a value abovei32::MAX. - Update
SwarmMetadata.downloadedanddownloads()to use theNumberOfDownloadsalias and add/update the subissue spec doc.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/tracker-core/src/databases/driver/sqlite/mod.rs | Extends SQLite idempotency test to assert _sqlx_migrations count is 4. |
| packages/tracker-core/src/databases/driver/mysql/mod.rs | Extends MySQL compatibility test to assert migration count/type widening and round-trip above i32::MAX; adds column-type assertion helper. |
| packages/tracker-core/migrations/sqlite/20260409120000_torrust_tracker_widen_download_counters.sql | Adds SQLite no-op migration #4 to align migration history. |
| packages/tracker-core/migrations/mysql/20260409120000_torrust_tracker_widen_download_counters.sql | Adds MySQL migration #4 to widen counter columns to BIGINT. |
| packages/primitives/src/swarm_metadata.rs | Switches downloaded and downloads() to use NumberOfDownloads alias. |
| docs/issues/1721-1525-07-align-rust-and-db-types.md | Adds updated spec describing “widen DB only” design and validation strategy. |
| docs/issues/1525-overhaul-persistence.md | Updates EPIC step 7 spec link to the new spec filename. |
| docs/issues/1525-07-align-rust-and-db-types.md | Removes the old spec doc (superseded by the new 1721-... file). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1722 +/- ##
===========================================
- Coverage 80.89% 80.79% -0.11%
===========================================
Files 348 348
Lines 25162 25208 +46
Branches 25162 25208 +46
===========================================
+ Hits 20356 20368 +12
- Misses 4579 4612 +33
- Partials 227 228 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
ACK d67efdd |
Implements subissue 1525-07 of the persistence overhaul (#1525): align Rust and database types by widening only MySQL download-counter columns to
BIGINTwhile keepingNumberOfDownloads = u32.Spec: docs/issues/1721-1525-07-align-rust-and-db-types.md
Closes #1721.
Scope
torrents.completed->BIGINT NOT NULL DEFAULT 0torrent_aggregate_metrics.value->BIGINT NOT NULL DEFAULT 0NumberOfDownloadsasu32(nou64widening).SwarmMetadata.downloadedanddownloads()to use theNumberOfDownloadsalias.Validation
4bigint2_200_000_000_u32(abovei32::MAX)_sqlx_migrationscount is4.cargo fmt --alllinter all