Something went wrong. Try again.
A simple to-do app focused on tasks that can be completed within a specific time span. taskline.tobinio.dev
Something went wrong. Try again.
Rust
at rust-backend
1234567891011121314151617181920212223use migration::{Migrator, MigratorTrait};use sea_orm::{ConnectOptions, ConnectionTrait, Database, DatabaseConnection, DbErr};
pub mod entities;
pub type OrmConnection = DatabaseConnection;
pub async fn init_db(url: &str) -> Result<OrmConnection, DbErr> { let mut options = ConnectOptions::new(url); options.sqlx_logging(false);
let connection = Database::connect(options).await?;
let connection = match connection.get_database_backend() { sea_orm::DatabaseBackend::Sqlite => connection, _ => panic!("Unsupported database backend"), };
Migrator::up(&connection, None).await?;
Ok(connection)}