fix: sqlite create_if_missing on connect
This commit is contained in:
@@ -3,6 +3,7 @@ use domain::{
|
||||
DomainError, Song, SongRepositoryPort, SongSummary, SortField, SortOrder, StoredSong,
|
||||
song_preview_chords,
|
||||
};
|
||||
use std::str::FromStr;
|
||||
use sqlx::SqlitePool;
|
||||
use uuid::Uuid;
|
||||
|
||||
@@ -15,7 +16,9 @@ pub struct SqliteSongRepository {
|
||||
|
||||
impl SqliteSongRepository {
|
||||
pub async fn new(database_url: &str) -> Result<Self, sqlx::Error> {
|
||||
let pool = SqlitePool::connect(database_url).await?;
|
||||
let opts = sqlx::sqlite::SqliteConnectOptions::from_str(database_url)?
|
||||
.create_if_missing(true);
|
||||
let pool = SqlitePool::connect_with(opts).await?;
|
||||
sqlx::migrate!("./migrations").run(&pool).await?;
|
||||
Ok(Self { pool })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user