rorm_declaration/config.rs
1//! This modules holds the definition of the configuration used by [rorm-cli]
2
3use serde::{Deserialize, Serialize};
4
5/**
6The representation of all supported DB drivers
7 */
8#[derive(Serialize, Deserialize, Debug, Clone)]
9#[serde(tag = "Driver")]
10pub enum DatabaseDriver {
11 /// Representation of the SQLite driver
12 #[cfg(feature = "sqlite")]
13 #[serde(rename_all = "PascalCase")]
14 SQLite {
15 /// The filename of the sqlite database
16 filename: String,
17 },
18 /// Representation of the Postgres driver
19 #[cfg(feature = "postgres")]
20 #[serde(rename_all = "PascalCase")]
21 Postgres {
22 /// Name of the database
23 name: String,
24 /// Host of the database
25 host: String,
26 /// Port of the database
27 port: u16,
28 /// User to connect to the database
29 user: String,
30 /// Password to connect to the database
31 password: String,
32 },
33 /// Representation of the MySQL / MariaDB driver
34 #[cfg(feature = "mysql")]
35 #[serde(rename_all = "PascalCase")]
36 MySQL {
37 /// Name of the database
38 name: String,
39 /// Host of the database
40 host: String,
41 /// Port of the database
42 port: u16,
43 /// User to connect to the database
44 user: String,
45 /// Password to connect to the database
46 password: String,
47 },
48}
49
50/**
51The configuration struct for database related settings
52 */
53#[derive(Serialize, Deserialize, Debug, Clone)]
54#[serde(rename_all = "PascalCase")]
55pub struct DatabaseConfig {
56 /// The representation of the SQL driver. Will be flattened
57 #[serde(flatten)]
58 pub driver: DatabaseDriver,
59 /// The name of the migration table. Only used be [rorm-cli].
60 pub last_migration_table_name: Option<String>,
61}