File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
beam-postgres/Database/Beam/Postgres Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ import qualified Database.PostgreSQL.Simple.TypeInfo.Static as Pg
55
55
56
56
import Control.Applicative ((<|>) )
57
57
import Control.Arrow
58
- import Control.Exception ( bracket )
58
+ import Control.Exception.Lifted ( mask , onException )
59
59
import Control.Monad
60
60
61
61
import Data.Aeson hiding (json )
@@ -106,9 +106,12 @@ migrationBackend = Tool.BeamMigrationBackend
106
106
, pgCustomEnumActionProvider
107
107
]
108
108
, Tool. backendRunSqlScript = \ t -> liftIOWithHandle (\ hdl -> void $ Pg. execute_ hdl (Pg. Query (TE. encodeUtf8 t)))
109
- , Tool. backendStartTransaction = liftIOWithHandle (void . Pg. begin)
110
- , Tool. backendCommitTransaction = liftIOWithHandle (void . Pg. commit)
111
- , Tool. backendAbortTransaction = liftIOWithHandle (void . Pg. rollback)
109
+ , Tool. backendWithTransaction =
110
+ \ go -> mask $ \ unmask -> do
111
+ liftIOWithHandle Pg. begin
112
+ x <- unmask go `onException` liftIOWithHandle Pg. rollback
113
+ liftIOWithHandle Pg. commit
114
+ pure x
112
115
, Tool. backendConnect = \ options -> do
113
116
conn <- Pg. connectPostgreSQL (fromString options)
114
117
pure Tool. BeamMigrateConnection
You can’t perform that action at this time.
0 commit comments