Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I4a6b498153eccd5407510dd541b7f4816a6a6964
26 lines
745 B
Rust
26 lines
745 B
Rust
use crate::error::{PinakesError, Result};
|
|
|
|
mod sqlite_migrations {
|
|
use refinery::embed_migrations;
|
|
embed_migrations!("../../migrations/sqlite");
|
|
}
|
|
|
|
mod postgres_migrations {
|
|
use refinery::embed_migrations;
|
|
embed_migrations!("../../migrations/postgres");
|
|
}
|
|
|
|
pub fn run_sqlite_migrations(conn: &mut rusqlite::Connection) -> Result<()> {
|
|
sqlite_migrations::migrations::runner()
|
|
.run(conn)
|
|
.map_err(|e| PinakesError::Migration(e.to_string()))?;
|
|
Ok(())
|
|
}
|
|
|
|
pub async fn run_postgres_migrations(client: &mut tokio_postgres::Client) -> Result<()> {
|
|
postgres_migrations::migrations::runner()
|
|
.run_async(client)
|
|
.await
|
|
.map_err(|e| PinakesError::Migration(e.to_string()))?;
|
|
Ok(())
|
|
}
|