This commit is contained in:
Billy Chan 2023-04-22 01:02:15 +08:00
parent c33cbb23fa
commit cf85d96e44
No known key found for this signature in database
GPG Key ID: A2D690CAC7DF3CC7

View File

@ -192,7 +192,7 @@ pub trait MigratorTrait: Send {
where where
C: IntoSchemaManagerConnection<'c>, C: IntoSchemaManagerConnection<'c>,
{ {
exec_with_connection::<'_, _, _, Self>(db, move |manager| { exec_with_connection::<'_, _, _>(db, move |manager| {
Box::pin(async move { exec_fresh::<Self>(manager).await }) Box::pin(async move { exec_fresh::<Self>(manager).await })
}) })
.await .await
@ -203,7 +203,7 @@ pub trait MigratorTrait: Send {
where where
C: IntoSchemaManagerConnection<'c>, C: IntoSchemaManagerConnection<'c>,
{ {
exec_with_connection::<'_, _, _, Self>(db, move |manager| { exec_with_connection::<'_, _, _>(db, move |manager| {
Box::pin(async move { Box::pin(async move {
exec_down::<Self>(manager, None).await?; exec_down::<Self>(manager, None).await?;
exec_up::<Self>(manager, None).await exec_up::<Self>(manager, None).await
@ -217,7 +217,7 @@ pub trait MigratorTrait: Send {
where where
C: IntoSchemaManagerConnection<'c>, C: IntoSchemaManagerConnection<'c>,
{ {
exec_with_connection::<'_, _, _, Self>(db, move |manager| { exec_with_connection::<'_, _, _>(db, move |manager| {
Box::pin(async move { exec_down::<Self>(manager, None).await }) Box::pin(async move { exec_down::<Self>(manager, None).await })
}) })
.await .await
@ -228,7 +228,7 @@ pub trait MigratorTrait: Send {
where where
C: IntoSchemaManagerConnection<'c>, C: IntoSchemaManagerConnection<'c>,
{ {
exec_with_connection::<'_, _, _, Self>(db, move |manager| { exec_with_connection::<'_, _, _>(db, move |manager| {
Box::pin(async move { exec_up::<Self>(manager, steps).await }) Box::pin(async move { exec_up::<Self>(manager, steps).await })
}) })
.await .await
@ -239,20 +239,19 @@ pub trait MigratorTrait: Send {
where where
C: IntoSchemaManagerConnection<'c>, C: IntoSchemaManagerConnection<'c>,
{ {
exec_with_connection::<'_, _, _, Self>(db, move |manager| { exec_with_connection::<'_, _, _>(db, move |manager| {
Box::pin(async move { exec_down::<Self>(manager, steps).await }) Box::pin(async move { exec_down::<Self>(manager, steps).await })
}) })
.await .await
} }
} }
async fn exec_with_connection<'c, C, F, M>(db: C, f: F) -> Result<(), DbErr> async fn exec_with_connection<'c, C, F>(db: C, f: F) -> Result<(), DbErr>
where where
C: IntoSchemaManagerConnection<'c>, C: IntoSchemaManagerConnection<'c>,
F: for<'b> Fn( F: for<'b> Fn(
&'b SchemaManager<'_>, &'b SchemaManager<'_>,
) -> Pin<Box<dyn Future<Output = Result<(), DbErr>> + Send + 'b>>, ) -> Pin<Box<dyn Future<Output = Result<(), DbErr>> + Send + 'b>>,
M: MigratorTrait + ?Sized,
{ {
let db = db.into_schema_manager_connection(); let db = db.into_schema_manager_connection();