@@ -41,7 +41,9 @@ type Schema =
44+type DB = '["public" ::: Schema]
44−setup :: Definition '[] Schema
46+setup :: Definition '["public" ::: '[]] DB
46 createTable #users
48 createTable #users
47 ( serial `as` #id :*
49 ( serial `as` #id :*
@@ -57,23 +59,23 @@ setup =
57 foreignKey #user_id #users #id
59 foreignKey #user_id #users #id
58 OnDeleteCascade OnUpdateCascade `as` #fk_user_id )
60 OnDeleteCascade OnUpdateCascade `as` #fk_user_id )
60−teardown :: Definition Schema '[]
62+teardown :: Definition DB '["public" ::: '[]]
61teardown = dropTable #emails >>> dropTable #users
63teardown = dropTable #emails >>> dropTable #users
63−insertUser :: Manipulation Schema '[ 'NotNull 'PGtext, 'NotNull ('PGvararray ('Null 'PGint2))]
65+insertUser :: Manipulation DB '[ 'NotNull 'PGtext, 'NotNull ('PGvararray ('Null 'PGint2))]
64 '[ "fromOnly" ::: 'NotNull 'PGint4 ]
66 '[ "fromOnly" ::: 'NotNull 'PGint4 ]
65insertUser = insertRows #users
67insertUser = insertRows #users
66 (Default `as` #id :* Set (param @1) `as` #name :* Set (param @2) `as` #vec) []
68 (Default `as` #id :* Set (param @1) `as` #name :* Set (param @2) `as` #vec) []
67 OnConflictDoNothing (Returning (#id `as` #fromOnly))
69 OnConflictDoNothing (Returning (#id `as` #fromOnly))
69−insertEmail :: Manipulation Schema '[ 'NotNull 'PGint4, 'Null 'PGtext] '[]
71+insertEmail :: Manipulation DB '[ 'NotNull 'PGint4, 'Null 'PGtext] '[]
70insertEmail = insertRows #emails
72insertEmail = insertRows #emails
71 ( Default `as` #id :*
73 ( Default `as` #id :*
72 Set (param @1) `as` #user_id :*
74 Set (param @1) `as` #user_id :*
73 Set (param @2) `as` #email ) []
75 Set (param @2) `as` #email ) []
74 OnConflictDoNothing (Returning Nil)
76 OnConflictDoNothing (Returning Nil)
76−getUsers :: Query Schema '[]
78+getUsers :: Query DB '[]
77 '[ "userName" ::: 'NotNull 'PGtext
79 '[ "userName" ::: 'NotNull 'PGtext
78 , "userEmail" ::: 'Null 'PGtext
80 , "userEmail" ::: 'Null 'PGtext
79 , "userVec" ::: 'NotNull ('PGvararray ('Null 'PGint2))]
81 , "userVec" ::: 'NotNull ('PGvararray ('Null 'PGint2))]
@@ -95,7 +97,7 @@ users =
95 , User "Carole" (Just "carole@hotmail.com") [Just 3]
97 , User "Carole" (Just "carole@hotmail.com") [Just 3]
98−session :: (MonadBase IO pq, MonadPQ Schema pq) => pq ()
100+session :: (MonadBase IO pq, MonadPQ DB pq) => pq ()
99session = do
101session = do
100 liftBase $ Char8.putStrLn "manipulating"
102 liftBase $ Char8.putStrLn "manipulating"
101 idResults <- traversePrepared insertUser ([(userName user, userVec user) | user <- users])
103 idResults <- traversePrepared insertUser ([(userName user, userVec user) | user <- users])