@@ -65,28 +65,20 @@ Now that we have a couple migrations we can chain them together.
66>>> let migrations = makeUsers :>> makeEmails :>> Done
66>>> let migrations = makeUsers :>> makeEmails :>> Done
68−>>> :{
68+Finally, we can run the migration and even roll it back.
71− :: Has "migrations" schemas MigrationsSchema
72− => PQ schemas schemas IO ()
74− result <- runQuery (select Star (from (table (#migrations ! #schema_migrations `as` #m))))
75− num <- ntuples result
70+>>> import Control.Monad.IO.Class
80withConnection "host=localhost port=5432 dbname=exampledb" $
72withConnection "host=localhost port=5432 dbname=exampledb" $
81 manipulate (UnsafeManipulation "SET client_min_messages TO WARNING;")
73 manipulate (UnsafeManipulation "SET client_min_messages TO WARNING;")
82 -- suppress notices
74 -- suppress notices
75+ & pqThen (liftIO (putStrLn "Migrate"))
83 & pqThen (migrateUp migrations)
76 & pqThen (migrateUp migrations)
84− & pqThen numMigrations
77+ & pqThen (liftIO (putStrLn "Rollback"))
85 & pqThen (migrateDown migrations)
78 & pqThen (migrateDown migrations)
86− & pqThen numMigrations
91{-# LANGUAGE DataKinds #-}
83{-# LANGUAGE DataKinds #-}
92{-# LANGUAGE DeriveGeneric #-}
84{-# LANGUAGE DeriveGeneric #-}