Skip to content

feat(tracker-core): widen mysql download counters to bigint (subissue 1525-07)#1722

Merged
josecelano merged 5 commits intotorrust:developfrom
josecelano:1721-1525-07-align-rust-and-db-types
May 1, 2026
Merged

feat(tracker-core): widen mysql download counters to bigint (subissue 1525-07)#1722
josecelano merged 5 commits intotorrust:developfrom
josecelano:1721-1525-07-align-rust-and-db-types

Conversation

@josecelano
Copy link
Copy Markdown
Member

Implements subissue 1525-07 of the persistence overhaul (#1525): align Rust and database types by widening only MySQL download-counter columns to BIGINT while keeping NumberOfDownloads = u32.

Spec: docs/issues/1721-1525-07-align-rust-and-db-types.md

Closes #1721.

Scope

  • Add migration 4 for MySQL to widen:
    • torrents.completed -> BIGINT NOT NULL DEFAULT 0
    • torrent_aggregate_metrics.value -> BIGINT NOT NULL DEFAULT 0
  • Add migration 4 for SQLite as a no-op to keep migration history aligned.
  • Keep NumberOfDownloads as u32 (no u64 widening).
  • Update SwarmMetadata.downloaded and downloads() to use the NumberOfDownloads alias.

Validation

  • MySQL db-compatibility test path now verifies migration outcomes:
    • migration history count is 4
    • both target columns are bigint
    • round-trip works for 2_200_000_000_u32 (above i32::MAX)
  • SQLite idempotency test now verifies _sqlx_migrations count is 4.
  • cargo fmt --all
  • linter all

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.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.completed and torrent_aggregate_metrics.value to BIGINT; SQLite adds a no-op migration to keep histories aligned.
  • Extend MySQL/SQLite driver tests to assert migration history count is 4 and validate MySQL round-trips a value above i32::MAX.
  • Update SwarmMetadata.downloaded and downloads() to use the NumberOfDownloads alias 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.

Comment thread docs/issues/1525-overhaul-persistence.md
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

❌ Patch coverage is 25.00000% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.79%. Comparing base (a370c3e) to head (d67efdd).
⚠️ Report is 6 commits behind head on develop.

Files with missing lines Patch % Lines
...ges/tracker-core/src/databases/driver/mysql/mod.rs 0.00% 35 Missing ⚠️
packages/primitives/src/swarm_metadata.rs 0.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@josecelano
Copy link
Copy Markdown
Member Author

ACK d67efdd

@josecelano josecelano merged commit 4cb8853 into torrust:develop May 1, 2026
22 of 23 checks passed
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.

1525-07: Align Rust and database types

2 participants