SI-27: Move Driver enum from configuration to primitives, remove duplicate in tracker-core#1921
Merged
josecelano merged 2 commits intoJun 19, 2026
Conversation
…es, remove duplicate in tracker-core This moves the cross-cutting Driver enum (Sqlite3, MySQL, PostgreSQL) to torrust-tracker-primitives, eliminating the duplicate copy in tracker-core and the identity mapping in setup.rs. - Add Driver enum with Serialize, Deserialize, Display, Hash, Ord, as_str(), and FromStr in packages/primitives/src/driver.rs - Re-export from packages/primitives/src/lib.rs - Remove Driver definition from packages/configuration/src/v2_0_0/database.rs - Remove pub type Driver re-export from packages/configuration/src/lib.rs - Remove duplicate Driver enum from packages/tracker-core/src/databases/driver/mod.rs - Simplify packages/tracker-core/src/databases/setup.rs (no identity mapping) - Update all consumers to import torrust_tracker_primitives::Driver - Record DEC-14 in docs/issues/open/1669-overhaul-packages/DECISIONS.md - Update issue spec torrust#1908 acceptance criteria Implements SI-27 of EPIC torrust#1669.
There was a problem hiding this comment.
Pull request overview
This PR implements SI-27 by centralizing the Driver enum (Sqlite3/MySQL/PostgreSQL) into torrust-tracker-primitives, removing duplicate definitions and simplifying consumers across the workspace.
Changes:
- Added
packages/primitives::Driver(new module + re-export) and updated consumers to import it. - Removed the duplicated
Driverenum fromtracker-coreand simplified database initialization logic accordingly. - Updated benchmark tooling, console E2E config builder, and docs/decisions to reflect the new ownership.
Reviewed changes
Copilot reviewed 23 out of 24 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/console/ci/qbittorrent_e2e/tracker/config_builder.rs | Switches Driver import to primitives for E2E config building. |
| packages/tracker-core/src/error.rs | Updates tests/imports to use primitives Driver. |
| packages/tracker-core/src/databases/setup.rs | Removes identity mapping and uses primitives Driver for DB selection. |
| packages/tracker-core/src/databases/error.rs | Switches DB error typing/tests to primitives Driver. |
| packages/tracker-core/src/databases/driver/mod.rs | Removes duplicate Driver enum definition from tracker-core. |
| packages/tracker-core/src/authentication/handler.rs | Updates tests/imports to use primitives Driver. |
| packages/primitives/src/lib.rs | Adds driver module and re-exports Driver. |
| packages/primitives/src/driver.rs | Introduces unified Driver enum + parsing/serialization/display/tests. |
| packages/primitives/Cargo.toml | Enables derive_more display feature; adds serde_json dev-dependency. |
| packages/persistence-benchmark/src/bin/persistence_benchmark/runner.rs | Switches benchmark CLI to primitives Driver. |
| packages/persistence-benchmark/src/bin/persistence_benchmark/reporting.rs | Switches reporting + tests to primitives Driver. |
| packages/persistence-benchmark/src/bin/persistence_benchmark/operations.rs | Switches operations to primitives Driver. |
| packages/persistence-benchmark/src/bin/persistence_benchmark/driver_bench/mod.rs | Switches bench driver selection to primitives Driver. |
| packages/persistence-benchmark/src/bin/persistence_benchmark/driver_bench/database/sqlite.rs | Uses primitives Driver when building benchmark config. |
| packages/persistence-benchmark/src/bin/persistence_benchmark/driver_bench/database/postgres.rs | Uses primitives Driver when building benchmark config. |
| packages/persistence-benchmark/src/bin/persistence_benchmark/driver_bench/database/mysql.rs | Uses primitives Driver when building benchmark config. |
| packages/persistence-benchmark/src/bin/persistence_benchmark/driver_bench/database/mod.rs | Switches DB initialization routing to primitives Driver. |
| packages/persistence-benchmark/Cargo.toml | Adds explicit dependency on primitives. |
| packages/configuration/src/v2_0_0/database.rs | Imports primitives Driver instead of defining it locally. |
| packages/configuration/src/lib.rs | Removes Driver type alias re-export. |
| docs/issues/open/1908-1669-si-27-move-driver-enum-to-primitives.md | Updates verification checklist for SI-27. |
| docs/issues/open/1669-overhaul-packages/DECISIONS.md | Adds DEC-14 documenting the move of Driver to primitives. |
| Cargo.toml | Adds root-crate dependency on primitives. |
| Cargo.lock | Records dependency graph changes (including serde_json). |
Comments suppressed due to low confidence (1)
packages/tracker-core/src/databases/setup.rs:100
driveris a&Driver, but thematcharms use non-reference patterns (Driver::Sqlite3, etc.). This does not type-check; either match on*driver(owned/cloned) or use reference patterns (&Driver::...).
let driver = &config.database.driver;
match driver {
Driver::Sqlite3 => {
let db = Arc::new(Sqlite::new(&config.database.path).expect("Database driver build failed."));
db.create_database_tables().await.expect("Could not create database tables.");
build_database_stores(db)
}
Driver::MySQL => {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…y PR review Corrects three documentation issues identified by copilot-pull-request-reviewer: - DECISIONS.md: CLI parity claim incorrectly mentioned clap::ValueEnum (actually FromStr/as_str()) - DECISIONS.md: trade-off listed clap dependency that was never added (actually serde_json dev-dep) - Issue spec checklist: said 're-exported from configuration' but re-export was removed
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1921 +/- ##
===========================================
+ Coverage 79.22% 79.42% +0.19%
===========================================
Files 326 327 +1
Lines 22981 23024 +43
Branches 22981 23024 +43
===========================================
+ Hits 18207 18287 +80
+ Misses 4508 4476 -32
+ Partials 266 261 -5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
Author
|
ACK 79eb106 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implements SI-27 (sub-issue of EPIC #1669, issue #1908).
Moves the
Driverenum (Sqlite3,MySQL,PostgreSQL) fromtorrust-tracker-configurationto
torrust-tracker-primitives, removes the duplicate copy intorrust-tracker-core, andeliminates the pointless identity mapping between the two.
Changes
primitivesdriver.rsmodule with unifiedDriverenum (Serialize,Deserialize,Display,Hash,Ord,as_str(),FromStr)configurationDriverenum definition andpub type Driverre-export; imports from primitivestracker-coreDriverenum (~60 lines); removed identity mapping insetup.rs; imports from primitivespersistence-benchmarktorrust-tracker-primitivesdep; updated all importssrc/console(root crate)Acceptance criteria
Driverdefined once in primitives, consumed by all packagestracker-corecargo test --workspace— all 2232 tests passcargo machete— no new unused depslinter all— passDECISIONS.mdCloses #1908