on dev help sign in
fix tests
263daa1Eitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL/Migration.hs+6−14
@@ -65,28 +65,20 @@ Now that we have a couple migrations we can chain them together.
65
65
66>>> let migrations = makeUsers :>> makeEmails :>> Done
66>>> let migrations = makeUsers :>> makeEmails :>> Done
67
67
68−>>> :{
68+Finally, we can run the migration and even roll it back.
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−:}
78
69
70+>>> import Control.Monad.IO.Class
79>>> :{
71>>> :{
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
87:}
79:}
88−Row 2
80+Migrate
89−Row 0
81+Rollback
90-}
82-}
91{-# LANGUAGE DataKinds #-}
83{-# LANGUAGE DataKinds #-}
92{-# LANGUAGE DeriveGeneric #-}
84{-# LANGUAGE DeriveGeneric #-}