feat(mint/sqlite): use sql migrations

This commit is contained in:
thesimplekid
2024-06-12 14:26:55 +01:00
parent 9377b71104
commit a07364c5c6
4 changed files with 9 additions and 48 deletions

View File

@@ -12,12 +12,10 @@ use cdk::secret::Secret;
use cdk::types::{MeltQuote, MintQuote};
use cdk::Amount;
use error::Error;
use migration::init_migration;
use sqlx::sqlite::{SqliteConnectOptions, SqlitePool, SqliteRow};
use sqlx::{ConnectOptions, Row};
pub mod error;
mod migration;
#[derive(Debug, Clone)]
pub struct MintSqliteDatabase {
@@ -36,10 +34,15 @@ impl MintSqliteDatabase {
let pool = SqlitePool::connect(path).await?;
init_migration(&pool).await?;
Ok(Self { pool })
}
pub async fn migrate(&self) {
sqlx::migrate!("./src/mint/migrations")
.run(&self.pool)
.await
.expect("Could not run migrations");
}
}
#[async_trait]