@@ -243,7 +243,7 @@ spec = do
243243 \ (col1 serial,\
244244 \ col2 text,\
245245 \ col3 int8 NOT NULL DEFAULT 8,\
246− \ CHECK (col3 > 0));"
246+ \ CHECK ((col3 > 0)));"
247247 let
248248 statement :: Definition '[]
249249 '[ "users" :::
@@ -267,6 +267,8 @@ spec = do
267267 (text & notNull) `As` #email :* Nil )
268268 [ primaryKey (Column #id :* Nil)
269269 , foreignKey (Column #userid :* Nil) #users (Column #id :* Nil)
270+ , unique (Column #email :* Nil)
271+ , check (#email /=* "")
270272 ]
271273 statement `definitionRenders`
272274 "CREATE TABLE users\
@@ -278,7 +280,9 @@ spec = do
278280 \ userid integer NOT NULL,\
279281 \ email text NOT NULL,\
280282 \ PRIMARY KEY (id),\
281− \ FOREIGN KEY (userid) REFERENCES users (id));"
283+ \ FOREIGN KEY (userid) REFERENCES users (id),\
284+ \ UNIQUE (email),\
285+ \ CHECK ((email <> E'')));"
282286 it "should render DROP TABLE statements" $ do
283287 let
284288 statement :: Definition Tables '[]