@@ -8,8 +8,8 @@ Stability: experimental
8This module defines a `Migration` type to safely
8This module defines a `Migration` type to safely
9change the schema of your database over time. Let's see an example!
9change the schema of your database over time. Let's see an example!
11−>>> :set -XDataKinds -XDeriveGeneric -XOverloadedLabels
11+>>> :set -XDataKinds -XOverloadedLabels
12−>>> :set -XOverloadedStrings -XTypeApplications -XTypeOperators
12+>>> :set -XOverloadedStrings -XFlexibleContexts -XTypeOperators
14type UsersTable =
14type UsersTable =
15 '[ "pk_users" ::: 'PrimaryKey '["id"] ] :=>
15 '[ "pk_users" ::: 'PrimaryKey '["id"] ] :=>
@@ -61,10 +61,26 @@ let
67+ :: Has "migration" schema MigrationTable
68+ => PQ schema schema IO ()
70+ result <- runQuery (selectStar (from (table (#migration `As` #m))))
71+ RowNumber num <- ntuples result
64>>> let migration = makeUsers :>> makeEmails :>> Done
75>>> let migration = makeUsers :>> makeEmails :>> Done
65−>>> withConnection "host=localhost port=5432 dbname=exampledb" (migrateUp migration)
77+withConnection "host=localhost port=5432 dbname=exampledb" $
80+ & pqThen (migrateDown migration)
66NOTICE: relation "migration" already exists, skipping
82NOTICE: relation "migration" already exists, skipping
67−>>> withConnection "host=localhost port=5432 dbname=exampledb" (migrateDown migration)
83+Row 2
68NOTICE: relation "migration" already exists, skipping
84NOTICE: relation "migration" already exists, skipping