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

This commit is contained in:
2024-09-24 14:20:55 +02:00
parent fcba21ef68
commit 777b7f2425
8 changed files with 38 additions and 14 deletions

11
crates/backend/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)
}