more migrations

This commit is contained in:
2023-08-29 21:34:00 +02:00
parent 1e121a9deb
commit 809615f3b9
3 changed files with 44 additions and 12 deletions

View File

@@ -12,7 +12,12 @@ pub async fn init_database_pool(url: &str) -> Result<Pool<Sqlite>, StartError> {
.await?)
}
pub async fn migrate(pool: &Pool<Sqlite>) -> Result<(), StartError> {
sqlx::migrate!().run(pool).await?;
pub async fn migrate(url: &str) -> Result<(), StartError> {
let pool = SqlitePoolOptions::new()
.max_connections(5)
.connect_with(SqliteConnectOptions::from_str(url)?.pragma("foreign_keys", "0"))
.await?;
sqlx::migrate!().run(&pool).await?;
Ok(())
}