feat: setup seaorm and a first "debug" entity as example

This commit is contained in:
2024-09-16 22:57:16 +02:00
parent 2ef527fa64
commit d43ee1c28f
20 changed files with 240 additions and 0 deletions

11
crates/app/src/db.rs Normal file
View File

@ -0,0 +1,11 @@
use migration::{Migrator, MigratorTrait};
use sea_orm::{Database, DatabaseConnection, DbErr};
use std::env;
pub async fn get_connection() -> Result<DatabaseConnection, DbErr> {
let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");
let db_connection = Database::connect(database_url).await?;
Migrator::up(&db_connection, None).await?;
Ok(db_connection)
}