-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: [#878] extract database section in core config section
- Loading branch information
1 parent
77dd938
commit 2f94f6c
Showing
14 changed files
with
92 additions
and
71 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use torrust_tracker_primitives::DatabaseDriver; | ||
|
||
#[allow(clippy::struct_excessive_bools)] | ||
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone)] | ||
pub struct Database { | ||
// Database configuration | ||
/// Database driver. Possible values are: `Sqlite3`, and `MySQL`. | ||
#[serde(default = "Database::default_driver")] | ||
pub driver: DatabaseDriver, | ||
|
||
/// Database connection string. The format depends on the database driver. | ||
/// For `Sqlite3`, the format is `path/to/database.db`, for example: | ||
/// `./storage/tracker/lib/database/sqlite3.db`. | ||
/// For `Mysql`, the format is `mysql://db_user:db_user_password:port/db_name`, for | ||
/// example: `root:password@localhost:3306/torrust`. | ||
#[serde(default = "Database::default_path")] | ||
pub path: String, | ||
} | ||
|
||
impl Default for Database { | ||
fn default() -> Self { | ||
Self { | ||
driver: Self::default_driver(), | ||
path: Self::default_path(), | ||
} | ||
} | ||
} | ||
|
||
impl Database { | ||
fn default_driver() -> DatabaseDriver { | ||
DatabaseDriver::Sqlite3 | ||
} | ||
|
||
fn default_path() -> String { | ||
String::from("./storage/tracker/lib/database/sqlite3.db") | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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