@@ -247,9 +247,9 @@ pureMigration migration = Migration
248instance Migratory (Terminally PQ IO) where
248instance Migratory (Terminally PQ IO) where
250− migrateUp migration = unsafePQ $
250+ migrateUp migration = unsafePQ . transactionally_ $ do
251 define createMigrations
251 define createMigrations
252− & pqThen (transactionally_ (upMigrations migration))
252+ upMigrations migration
@@ -258,30 +258,27 @@ instance Migratory (Terminally PQ IO) where
258 -> PQ MigrationsSchemas MigrationsSchemas IO ()
258 -> PQ MigrationsSchemas MigrationsSchemas IO ()
259 upMigrations = \case
259 upMigrations = \case
260 Done -> return ()
260 Done -> return ()
261− step :>> steps -> upMigration step & pqThen (upMigrations steps)
261+ step :>> steps -> upMigration step >> upMigrations steps
263 upMigration
263 upMigration
264 :: Migration (Terminally PQ IO) schemas0 schemas1
264 :: Migration (Terminally PQ IO) schemas0 schemas1
265 -> PQ MigrationsSchemas MigrationsSchemas IO ()
265 -> PQ MigrationsSchemas MigrationsSchemas IO ()
266− upMigration step =
266+ upMigration step = do
267− queryExecuted step
267+ executed <- queryExecuted step
268− & pqBind ( \ executed -> unless (executed == 1)
268+ unless (executed == 1) $ do
269− $ unsafePQ (runTerminally (up step))
269+ unsafePQ . runTerminally $ up step
270− & pqThen (manipulateParams insertMigration (Only (name step)))
270+ manipulateParams_ insertMigration (Only (name step))
271− -- insert execution record
274 queryExecuted
272 queryExecuted
275 :: Migration (Terminally PQ IO) schemas0 schemas1
273 :: Migration (Terminally PQ IO) schemas0 schemas1
276 -> PQ MigrationsSchemas MigrationsSchemas IO Row
274 -> PQ MigrationsSchemas MigrationsSchemas IO Row
277 queryExecuted step = do
275 queryExecuted step = do
278 result <- runQueryParams selectMigration (Only (name step))
276 result <- runQueryParams selectMigration (Only (name step))
280 ntuples result
277 ntuples result
282− migrateDown migrations = unsafePQ $
279+ migrateDown migrations = unsafePQ . transactionally_ $ do
283 define createMigrations
280 define createMigrations
284− & pqThen (transactionally_ (downMigrations migrations))
281+ downMigrations migrations
@@ -290,25 +287,22 @@ instance Migratory (Terminally PQ IO) where
290 -> PQ MigrationsSchemas MigrationsSchemas IO ()
287 -> PQ MigrationsSchemas MigrationsSchemas IO ()
291 downMigrations = \case
288 downMigrations = \case
292 Done -> return ()
289 Done -> return ()
293− step :>> steps -> downMigrations steps & pqThen (downMigration step)
290+ step :>> steps -> downMigrations steps >> downMigration step
295 downMigration
292 downMigration
296 :: Migration (Terminally PQ IO) schemas0 schemas1
293 :: Migration (Terminally PQ IO) schemas0 schemas1
297 -> PQ MigrationsSchemas MigrationsSchemas IO ()
294 -> PQ MigrationsSchemas MigrationsSchemas IO ()
298− downMigration step =
295+ downMigration step = do
299− queryExecuted step
296+ executed <- queryExecuted step
300− & pqBind ( \ executed -> unless (executed == 0)
297+ unless (executed == 0) $ do
301− $ unsafePQ (runTerminally (down step))
298+ unsafePQ . runTerminally $ down step
302− & pqThen (manipulateParams deleteMigration (Only (name step)))
299+ manipulateParams_ deleteMigration (Only (name step))
303− -- delete execution record
306 queryExecuted
301 queryExecuted
307 :: Migration (Terminally PQ IO) schemas0 schemas1
302 :: Migration (Terminally PQ IO) schemas0 schemas1
308 -> PQ MigrationsSchemas MigrationsSchemas IO Row
303 -> PQ MigrationsSchemas MigrationsSchemas IO Row
309 queryExecuted step = do
304 queryExecuted step = do
310 result <- runQueryParams selectMigration (Only (name step))
305 result <- runQueryParams selectMigration (Only (name step))
312 ntuples result
306 ntuples result
314unsafePQ :: (Functor m) => PQ db0 db1 m x -> PQ db0' db1' m x
308unsafePQ :: (Functor m) => PQ db0 db1 m x -> PQ db0' db1' m x