Setup database #1
@@ -1,6 +1,7 @@
|
||||
[workspace]
|
||||
members = [
|
||||
"apps/container",
|
||||
"apps/shared",
|
||||
"public/database",
|
||||
"public/migration"
|
||||
]
|
||||
|
||||
10
public/shared/Cargo.toml
Normal file
10
public/shared/Cargo.toml
Normal file
@@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "shared"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[lib]
|
||||
path = "src/lib.rs"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
28
public/shared/src/db_type.rs
Normal file
28
public/shared/src/db_type.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
use std::str::FromStr;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum DBType {
|
||||
PostgreSQL,
|
||||
SQLite,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for DBType {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
DBType::PostgreSQL => write!(f, "PostgreSQL"),
|
||||
DBType::SQLite => write!(f, "SQLite"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for DBType {
|
||||
type Err = String;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s.to_lowercase().as_str() {
|
||||
"postgresql" | "postgres" => Ok(DBType::PostgreSQL),
|
||||
"sqlite" => Ok(DBType::SQLite),
|
||||
_ => Err(format!("Unknown DBType: {}", s)),
|
||||
}
|
||||
}
|
||||
}
|
||||
1
public/shared/src/lib.rs
Normal file
1
public/shared/src/lib.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub mod db_type;
|
||||
Reference in New Issue
Block a user