feat(wallet/sqlite): use sqlx migration

This commit is contained in:
thesimplekid
2024-06-12 14:33:04 +01:00
parent a07364c5c6
commit 971fd30d8d
2 changed files with 7 additions and 48 deletions

View File

@@ -17,10 +17,7 @@ use error::Error;
use sqlx::sqlite::{SqliteConnectOptions, SqlitePool, SqliteRow};
use sqlx::{ConnectOptions, Row};
use self::migration::init_migration;
pub mod error;
mod migration;
#[derive(Debug, Clone)]
pub struct WalletSQLiteDatabase {
@@ -39,10 +36,15 @@ impl WalletSQLiteDatabase {
let pool = SqlitePool::connect(path).await?;
init_migration(&pool).await?;
Ok(Self { pool })
}
pub async fn migrate(&self) {
sqlx::migrate!("./src/wallet/migrations")
.run(&self.pool)
.await
.expect("Could not run migrations");
}
}
#[async_trait]