added database_pool crate, for pool handling and migrations
This commit is contained in:
parent
27d02a0d5c
commit
f60eb616d3
11 changed files with 197 additions and 0 deletions
15
crates/database_pool/src/migrations.rs
Normal file
15
crates/database_pool/src/migrations.rs
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue