@@ -34,7 +34,7 @@ pub async fn apply_migration(
3434 } ) ?;
3535
3636 for ( index, operation) in migration. operations . iter ( ) . enumerate ( ) {
37- apply_operation ( tx . get_transaction ( ) , operation)
37+ apply_operation ( & mut tx , operation)
3838 . await
3939 . map_err ( |error| ApplyMigrationError {
4040 error,
@@ -43,7 +43,6 @@ pub async fn apply_migration(
4343 }
4444
4545 let ( query_string, bind_params) = tx
46- . get_transaction ( )
4746 . dialect ( )
4847 . insert (
4948 last_migration_table_name,
@@ -54,21 +53,22 @@ pub async fn apply_migration(
5453 . rollback_transaction ( )
5554 . build ( ) ;
5655
57- tx. get_transaction ( )
58- . execute :: < Nothing > ( query_string, bind_params)
56+ tx. execute :: < Nothing > ( query_string, bind_params)
5957 . await
6058 . map_err ( |error| ApplyMigrationError {
6159 error,
6260 location : ApplyMigrationErrorLocation :: UpdateLastMigration ,
6361 } ) ?;
6462
65- tx. commit ( ) . await . map_err ( |x| ApplyMigrationError {
66- error : match x {
67- TransactionError :: Database ( x) => x,
68- TransactionError :: Hook ( _) => unreachable ! ( "rorm-cli does not use hooks" ) ,
69- } ,
70- location : ApplyMigrationErrorLocation :: CommitTransaction ,
71- } ) ?;
63+ tx. commit_if_owned ( )
64+ . await
65+ . map_err ( |x| ApplyMigrationError {
66+ error : match x {
67+ TransactionError :: Database ( x) => x,
68+ TransactionError :: Hook ( _) => unreachable ! ( "rorm-cli does not use hooks" ) ,
69+ } ,
70+ location : ApplyMigrationErrorLocation :: CommitTransaction ,
71+ } ) ?;
7272
7373 Ok ( ( ) )
7474}
0 commit comments