@@ -25,12 +25,14 @@ import qualified GHC.Generics as GHC
2525
2626type Schema =
2727 '[ "users" :::
28− '[] :=>
28+ '[ "pk_id" ::: 'PrimaryKey '["id"] ] :=>
2929 '[ "id" ::: 'Def :=> 'NotNull 'PGint4
3030 , "name" ::: 'NoDef :=> 'NotNull 'PGtext
3131 ]
3232 , "emails" :::
33− '[ "fk_user_id" ::: 'ForeignKey '["user_id"] "users" '["id"] ] :=>
33+ '[ "pk_id" ::: 'PrimaryKey '["id"]
34+ , "fk_user_id" ::: 'ForeignKey '["user_id"] "users" '["id"]
35+ ] :=>
3436 '[ "id" ::: 'Def :=> 'NotNull 'PGint4
3537 , "user_id" ::: 'NoDef :=> 'NotNull 'PGint4
3638 , "email" ::: 'NoDef :=> 'Null 'PGtext
@@ -41,14 +43,16 @@ setup :: Definition '[] Schema
4143setup =
4244 createTable #users
4345 ( serial `As` #id :*
44− (text & notNull) `As` #name :* Nil ) Nil
46+ (text & notNull) `As` #name :* Nil )
47+ ( primaryKey (Column #id :* Nil) `As` #pk_id :* Nil )
4548 >>>
4649 createTable #emails
4750 ( serial `As` #id :*
4851 (int & notNull) `As` #user_id :*
4952 text `As` #email :* Nil )
50− ( (foreignKey (Column #user_id :* Nil) #users (Column #id :* Nil)
51− OnDeleteCascade OnUpdateCascade) `As` #fk_user_id :* Nil)
53+ ( primaryKey (Column #id :* Nil) `As` #pk_id :*
54+ foreignKey (Column #user_id :* Nil) #users (Column #id :* Nil)
55+ OnDeleteCascade OnUpdateCascade `As` #fk_user_id :* Nil )
5256
5357teardown :: Definition Schema '[]
5458teardown = dropTable #emails >>> dropTable #users