@@ -247,9 +247,9 @@ pureMigration migration = Migration
247247
248248instance Migratory (Terminally PQ IO) where
249249
250− migrateUp migration = unsafePQ $
250+ migrateUp migration = unsafePQ . transactionally_ $ do
251251 define createMigrations
252− & pqThen (transactionally_ (upMigrations migration))
252+ upMigrations migration
253253
254254 where
255255
@@ -258,30 +258,27 @@ instance Migratory (Terminally PQ IO) where
258258 -> PQ MigrationsSchemas MigrationsSchemas IO ()
259259 upMigrations = \case
260260 Done -> return ()
261− step :>> steps -> upMigration step & pqThen (upMigrations steps)
261+ step :>> steps -> upMigration step >> upMigrations steps
262262
263263 upMigration
264264 :: Migration (Terminally PQ IO) schemas0 schemas1
265265 -> PQ MigrationsSchemas MigrationsSchemas IO ()
266− upMigration step =
267− queryExecuted step
268− & pqBind ( \ executed -> unless (executed == 1)
269− $ unsafePQ (runTerminally (up step))
270− & pqThen (manipulateParams insertMigration (Only (name step)))
271− -- insert execution record
272− & pqBind okResult )
266+ upMigration step = do
267+ executed <- queryExecuted step
268+ unless (executed == 1) $ do
269+ unsafePQ . runTerminally $ up step
270+ manipulateParams_ insertMigration (Only (name step))
273271
274272 queryExecuted
275273 :: Migration (Terminally PQ IO) schemas0 schemas1
276274 -> PQ MigrationsSchemas MigrationsSchemas IO Row
277275 queryExecuted step = do
278276 result <- runQueryParams selectMigration (Only (name step))
279− okResult result
280277 ntuples result
281278
282− migrateDown migrations = unsafePQ $
279+ migrateDown migrations = unsafePQ . transactionally_ $ do
283280 define createMigrations
284− & pqThen (transactionally_ (downMigrations migrations))
281+ downMigrations migrations
285282
286283 where
287284
@@ -290,25 +287,22 @@ instance Migratory (Terminally PQ IO) where
290287 -> PQ MigrationsSchemas MigrationsSchemas IO ()
291288 downMigrations = \case
292289 Done -> return ()
293− step :>> steps -> downMigrations steps & pqThen (downMigration step)
290+ step :>> steps -> downMigrations steps >> downMigration step
294291
295292 downMigration
296293 :: Migration (Terminally PQ IO) schemas0 schemas1
297294 -> PQ MigrationsSchemas MigrationsSchemas IO ()
298− downMigration step =
299− queryExecuted step
300− & pqBind ( \ executed -> unless (executed == 0)
301− $ unsafePQ (runTerminally (down step))
302− & pqThen (manipulateParams deleteMigration (Only (name step)))
303− -- delete execution record
304− & pqBind okResult )
295+ downMigration step = do
296+ executed <- queryExecuted step
297+ unless (executed == 0) $ do
298+ unsafePQ . runTerminally $ down step
299+ manipulateParams_ deleteMigration (Only (name step))
305300
306301 queryExecuted
307302 :: Migration (Terminally PQ IO) schemas0 schemas1
308303 -> PQ MigrationsSchemas MigrationsSchemas IO Row
309304 queryExecuted step = do
310305 result <- runQueryParams selectMigration (Only (name step))
311− okResult result
312306 ntuples result
313307
314308unsafePQ :: (Functor m) => PQ db0 db1 m x -> PQ db0' db1' m x