feat: more task system

This commit is contained in:
2025-05-10 02:34:11 +08:00
parent 9d58d961bd
commit d4bdc677a9
43 changed files with 1180 additions and 835 deletions

View File

@@ -52,19 +52,34 @@ impl DatabaseService {
// .await?;
// }
if config.auto_migrate {
Migrator::up(&db, None).await?;
{
let pool = db.get_postgres_connection_pool();
PostgresStorage::setup(pool).await?;
}
}
Ok(Self {
let me = Self {
connection: db,
#[cfg(all(test, feature = "testcontainers"))]
container: None,
})
};
if config.auto_migrate {
me.migrate_up().await?;
}
Ok(me)
}
pub async fn migrate_up(&self) -> RecorderResult<()> {
Migrator::up(&self.connection, None).await?;
{
let pool = &self.get_postgres_connection_pool();
PostgresStorage::setup(pool).await?;
}
Ok(())
}
pub async fn migrate_down(&self) -> RecorderResult<()> {
Migrator::down(&self.connection, None).await?;
{
let _pool = &self.get_postgres_connection_pool();
}
Ok(())
}
}