Skip to content

Commit 9045b21

Browse files
committed
Fix build for beam-postgres
1 parent b770765 commit 9045b21

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

beam-postgres/Database/Beam/Postgres/Migrate.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import qualified Database.PostgreSQL.Simple.TypeInfo.Static as Pg
5555

5656
import Control.Applicative ((<|>))
5757
import Control.Arrow
58-
import Control.Exception (bracket)
58+
import Control.Exception.Lifted (mask, onException)
5959
import Control.Monad
6060

6161
import Data.Aeson hiding (json)
@@ -106,9 +106,12 @@ migrationBackend = Tool.BeamMigrationBackend
106106
, pgCustomEnumActionProvider
107107
]
108108
, 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
112115
, Tool.backendConnect = \options -> do
113116
conn <- Pg.connectPostgreSQL (fromString options)
114117
pure Tool.BeamMigrateConnection

0 commit comments

Comments
 (0)