@@ -65,28 +65,20 @@ Now that we have a couple migrations we can chain them together.
6565
6666>>> let migrations = makeUsers :>> makeEmails :>> Done
6767
68−>>> :{
69−let
70− numMigrations
71− :: Has "migrations" schemas MigrationsSchema
72− => PQ schemas schemas IO ()
73− numMigrations = do
74− result <- runQuery (select Star (from (table (#migrations ! #schema_migrations `as` #m))))
75− num <- ntuples result
76− liftBase $ print num
77−:}
68+Finally, we can run the migration and even roll it back.
7869
70+>>> import Control.Monad.IO.Class
7971>>> :{
8072withConnection "host=localhost port=5432 dbname=exampledb" $
8173 manipulate (UnsafeManipulation "SET client_min_messages TO WARNING;")
8274 -- suppress notices
75+ & pqThen (liftIO (putStrLn "Migrate"))
8376 & pqThen (migrateUp migrations)
84− & pqThen numMigrations
77+ & pqThen (liftIO (putStrLn "Rollback"))
8578 & pqThen (migrateDown migrations)
86− & pqThen numMigrations
8779:}
88−Row 2
89−Row 0
80+Migrate
81+Rollback
9082-}
9183{-# LANGUAGE DataKinds #-}
9284{-# LANGUAGE DeriveGeneric #-}