mirror of
https://github.com/aljazceru/cdk.git
synced 2025-12-19 21:55:03 +01:00
feat(mint/sqlite): use sql migrations
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user