added database_pool crate, for pool handling and migrations

This commit is contained in:
Philippe Loctaux 2023-02-27 14:36:48 +01:00
parent 27d02a0d5c
commit f60eb616d3
11 changed files with 197 additions and 0 deletions

View file

@ -0,0 +1,15 @@
use sqlx::migrate::MigrateError;
use sqlx::{Pool, Sqlite};
pub async fn run_migrations(pool: &Pool<Sqlite>) -> Result<(), MigrateError> {
match sqlx::migrate!("../database").run(pool).await {
Ok(ok) => {
println!("Migrations are OK");
Ok(ok)
}
Err(e) => {
eprintln!("Failed to run migrations!");
Err(e)
}
}
}