embed migrations, fix start, add stop

This commit is contained in:
2026-06-09 17:09:07 +02:00
parent 5136e0bdc3
commit 408530db00
16 changed files with 212 additions and 26 deletions

19
src/migrations.rs Normal file
View File

@ -0,0 +1,19 @@
use std::error::Error;
use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness};
use crate::DbPool;
pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!("./migrations");
pub fn run_migrations(pool: &DbPool) -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
// This will run the necessary migrations.
//
// See the documentation for `MigrationHarness` for
// all available methods.
let connection = &mut pool.get().unwrap();
connection.run_pending_migrations(MIGRATIONS)?;
Ok(())
}