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}
34
35/**
36The configuration struct for database related settings
37 */
38#[derive(Serialize, Deserialize, Debug, Clone)]
39#[serde(rename_all = "PascalCase")]
40pub struct DatabaseConfig {
41 /// The representation of the SQL driver. Will be flattened
42 #[serde(flatten)]
43 pub driver: DatabaseDriver,
44 /// The name of the migration table. Only used be [rorm-cli].
45 pub last_migration_table_name: Option<String>,
46}