git.iko.soy/rowtype-yoga/purescript-yoga-postgres-om
on main help sign in
checkpoint
ecd434aMark
test/Test/.psc-ide-portnew file+1
@@ -0,0 +1 @@
1+15143
test/Test/ClientOm.purs+198−202
@@ -36,208 +36,6 @@ import Yoga.Postgres.ClientOm
36 )
36 )
37import Yoga.Postgres.Schema (Table, PrimaryKey, AutoIncrement, Unique, Default, DefaultExpr, ForeignKey, References, PGUUID)
37import Yoga.Postgres.Schema (Table, PrimaryKey, AutoIncrement, Unique, Default, DefaultExpr, ForeignKey, References, PGUUID)
38
38
39−-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
40−-- Test schemas
41−-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
42−
43−type UsersTable = Table "test_om_users"
44− ( id :: PrimaryKey (AutoIncrement Int)
45− , name :: String
46− , email :: Unique String
47− , active :: Default "true" Boolean
48− , role :: String
49− )
50−
51−usersTable :: Proxy UsersTable
52−usersTable = Proxy
53−
54−type SettingsTable = Table "test_om_settings"
55− ( key :: PrimaryKey String
56− , value :: String
57− )
58−
59−settingsTable :: Proxy SettingsTable
60−settingsTable = Proxy
61−
62−type UuidTable = Table "test_om_uuid_things"
63− ( id :: PGUUID # PrimaryKey # DefaultExpr "gen_random_uuid()"
64− , label :: String
65− )
66−
67−uuidTable :: Proxy UuidTable
68−uuidTable = Proxy
69−
70−type PostsTable = Table "test_om_posts"
71− ( id :: PrimaryKey (AutoIncrement Int)
72− , title :: String
73− , body :: String
74− , user_id :: ForeignKey "test_om_users" References "id" Int
75− )
76−
77−postsTable :: Proxy PostsTable
78−postsTable = Proxy
79−
80−type CommentsTable = Table "test_om_comments"
81− ( id :: PrimaryKey (AutoIncrement Int)
82− , text :: String
83− , user_id :: ForeignKey "test_om_users" References "id" Int
84− )
85−
86−commentsTable :: Proxy CommentsTable
87−commentsTable = Proxy
88−
89−-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
90−-- Helpers
91−-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
92−
93−testConnection :: Aff PG.Connection
94−testConnection =
95− PG.postgres
96− { host: PG.PostgresHost "localhost"
97− , port: PG.PostgresPort 5433
98− , database: PG.PostgresDatabase "test_playground"
99− , username: PG.PostgresUsername "postgres"
100− , password: PG.PostgresPassword "postgres"
101− } # liftEffect
102−
103−run
104− :: forall a
105− . Om.Om { postgresConnection :: PG.Connection } (parseError :: MultipleErrors) a
106− -> PG.Connection
107− -> Aff a
108−run om conn = Om.runOm { postgresConnection: conn }
109− { exception: \e -> throwError e
110− , parseError: \errs -> throwError (error ("Parse error: " <> show errs))
111− }
112− om
113−
114−runNoErr
115− :: forall a
116− . Om.Om { postgresConnection :: PG.Connection } () a
117− -> PG.Connection
118− -> Aff a
119−runNoErr om conn = Om.runOm { postgresConnection: conn }
120− { exception: \e -> throwError e }
121− om
122−
123−withUsersTable :: (PG.Connection -> Aff Unit) -> Aff Unit
124−withUsersTable test = do
125− conn <- testConnection
126− _ <- PG.executeSimple createDDL conn
127− test conn
128− _ <- PG.executeSimple dropDDL conn
129− PG.end conn
130− where
131− dropDDL = PG.SQL "DROP TABLE IF EXISTS test_om_users CASCADE"
132− createDDL = PG.SQL
133− """DROP TABLE IF EXISTS test_om_users CASCADE;
134− CREATE TABLE test_om_users (
135− id SERIAL PRIMARY KEY,
136− name TEXT NOT NULL,
137− email TEXT UNIQUE NOT NULL,
138− active BOOLEAN DEFAULT true NOT NULL,
139− role TEXT NOT NULL
140− )"""
141−
142−withSettingsTable :: (PG.Connection -> Aff Unit) -> Aff Unit
143−withSettingsTable test = do
144− conn <- testConnection
145− _ <- PG.executeSimple createDDL conn
146− test conn
147− _ <- PG.executeSimple dropDDL conn
148− PG.end conn
149− where
150− dropDDL = PG.SQL "DROP TABLE IF EXISTS test_om_settings CASCADE"
151− createDDL = PG.SQL
152− """DROP TABLE IF EXISTS test_om_settings CASCADE;
153− CREATE TABLE test_om_settings (
154− key TEXT PRIMARY KEY,
155− value TEXT NOT NULL
156− )"""
157−
158−withUuidTable :: (PG.Connection -> Aff Unit) -> Aff Unit
159−withUuidTable test = do
160− conn <- testConnection
161− _ <- PG.executeSimple createDDL conn
162− test conn
163− _ <- PG.executeSimple dropDDL conn
164− PG.end conn
165− where
166− dropDDL = PG.SQL "DROP TABLE IF EXISTS test_om_uuid_things CASCADE"
167− createDDL = PG.SQL
168− """DROP TABLE IF EXISTS test_om_uuid_things CASCADE;
169− CREATE TABLE test_om_uuid_things (
170− id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
171− label TEXT NOT NULL
172− )"""
173−
174−withPostsTable :: (PG.Connection -> Aff Unit) -> Aff Unit
175−withPostsTable test = do
176− conn <- testConnection
177− _ <- PG.executeSimple createDDL conn
178− test conn
179− _ <- PG.executeSimple (PG.SQL "DROP TABLE IF EXISTS test_om_posts CASCADE") conn
180− _ <- PG.executeSimple (PG.SQL "DROP TABLE IF EXISTS test_om_users CASCADE") conn
181− PG.end conn
182− where
183− createDDL = PG.SQL
184− """DROP TABLE IF EXISTS test_om_posts CASCADE;
185− DROP TABLE IF EXISTS test_om_users CASCADE;
186− CREATE TABLE test_om_users (
187− id SERIAL PRIMARY KEY,
188− name TEXT NOT NULL,
189− email TEXT UNIQUE NOT NULL,
190− active BOOLEAN DEFAULT true NOT NULL,
191− role TEXT NOT NULL
192− );
193− CREATE TABLE test_om_posts (
194− id SERIAL PRIMARY KEY,
195− title TEXT NOT NULL,
196− body TEXT NOT NULL,
197− user_id INTEGER NOT NULL REFERENCES test_om_users(id)
198− )"""
199−
200−withPostsAndCommentsTable :: (PG.Connection -> Aff Unit) -> Aff Unit
201−withPostsAndCommentsTable test = do
202− conn <- testConnection
203− _ <- PG.executeSimple createDDL conn
204− test conn
205− _ <- PG.executeSimple (PG.SQL "DROP TABLE IF EXISTS test_om_comments CASCADE") conn
206− _ <- PG.executeSimple (PG.SQL "DROP TABLE IF EXISTS test_om_posts CASCADE") conn
207− _ <- PG.executeSimple (PG.SQL "DROP TABLE IF EXISTS test_om_users CASCADE") conn
208− PG.end conn
209− where
210− createDDL = PG.SQL
211− """DROP TABLE IF EXISTS test_om_comments CASCADE;
212− DROP TABLE IF EXISTS test_om_posts CASCADE;
213− DROP TABLE IF EXISTS test_om_users CASCADE;
214− CREATE TABLE test_om_users (
215− id SERIAL PRIMARY KEY,
216− name TEXT NOT NULL,
217− email TEXT UNIQUE NOT NULL,
218− active BOOLEAN DEFAULT true NOT NULL,
219− role TEXT NOT NULL
220− );
221− CREATE TABLE test_om_posts (
222− id SERIAL PRIMARY KEY,
223− title TEXT NOT NULL,
224− body TEXT NOT NULL,
225− user_id INTEGER NOT NULL REFERENCES test_om_users(id)
226− );
227− CREATE TABLE test_om_comments (
228− id SERIAL PRIMARY KEY,
229− text TEXT NOT NULL,
230− user_id INTEGER NOT NULL REFERENCES test_om_users(id)
231− )"""
232−
233−shouldBeJust :: forall a. Maybe a -> Aff a
234−shouldBeJust (Just a) = pure a
235−shouldBeJust Nothing = throwError $ error "Expected Just but got Nothing"
236−
237−-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
238−-- Spec
239−-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
240−
241spec :: Spec Unit
39spec :: Spec Unit
242spec = describe "ClientOm" do
40spec = describe "ClientOm" do
243
41
@@ -789,3 +587,201 @@ spec = describe "ClientOm" do
789 r3.label `shouldEqual` "first"
587 r3.label `shouldEqual` "first"
790 yes <- conn # runNoErr do uuidTable # exists row.id
588 yes <- conn # runNoErr do uuidTable # exists row.id
791 yes `shouldEqual` true
589 yes `shouldEqual` true
590+
591+-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
592+-- Test schemas
593+-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
594+
595+type UsersTable = Table "test_om_users"
596+ ( id :: PrimaryKey (AutoIncrement Int)
597+ , name :: String
598+ , email :: Unique String
599+ , active :: Default "true" Boolean
600+ , role :: String
601+ )
602+
603+usersTable :: Proxy UsersTable
604+usersTable = Proxy
605+
606+type SettingsTable = Table "test_om_settings"
607+ ( key :: PrimaryKey String
608+ , value :: String
609+ )
610+
611+settingsTable :: Proxy SettingsTable
612+settingsTable = Proxy
613+
614+type UuidTable = Table "test_om_uuid_things"
615+ ( id :: PGUUID # PrimaryKey # DefaultExpr "gen_random_uuid()"
616+ , label :: String
617+ )
618+
619+uuidTable :: Proxy UuidTable
620+uuidTable = Proxy
621+
622+type PostsTable = Table "test_om_posts"
623+ ( id :: PrimaryKey (AutoIncrement Int)
624+ , title :: String
625+ , body :: String
626+ , user_id :: ForeignKey "test_om_users" References "id" Int
627+ )
628+
629+postsTable :: Proxy PostsTable
630+postsTable = Proxy
631+
632+type CommentsTable = Table "test_om_comments"
633+ ( id :: PrimaryKey (AutoIncrement Int)
634+ , text :: String
635+ , user_id :: ForeignKey "test_om_users" References "id" Int
636+ )
637+
638+commentsTable :: Proxy CommentsTable
639+commentsTable = Proxy
640+
641+-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
642+-- Helpers
643+-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
644+
645+testConnection :: Aff PG.Connection
646+testConnection =
647+ PG.postgres
648+ { host: PG.PostgresHost "localhost"
649+ , port: PG.PostgresPort 5433
650+ , database: PG.PostgresDatabase "test_playground"
651+ , username: PG.PostgresUsername "postgres"
652+ , password: PG.PostgresPassword "postgres"
653+ } # liftEffect
654+
655+run
656+ :: forall a
657+ . Om.Om { postgresConnection :: PG.Connection } (parseError :: MultipleErrors) a
658+ -> PG.Connection
659+ -> Aff a
660+run om conn = Om.runOm { postgresConnection: conn }
661+ { exception: \e -> throwError e
662+ , parseError: \errs -> throwError (error ("Parse error: " <> show errs))
663+ }
664+ om
665+
666+runNoErr
667+ :: forall a
668+ . Om.Om { postgresConnection :: PG.Connection } () a
669+ -> PG.Connection
670+ -> Aff a
671+runNoErr om conn = Om.runOm { postgresConnection: conn }
672+ { exception: \e -> throwError e }
673+ om
674+
675+withUsersTable :: (PG.Connection -> Aff Unit) -> Aff Unit
676+withUsersTable test = do
677+ conn <- testConnection
678+ _ <- PG.executeSimple createDDL conn
679+ test conn
680+ _ <- PG.executeSimple dropDDL conn
681+ PG.end conn
682+ where
683+ dropDDL = PG.SQL "DROP TABLE IF EXISTS test_om_users CASCADE"
684+ createDDL = PG.SQL
685+ """DROP TABLE IF EXISTS test_om_users CASCADE;
686+ CREATE TABLE test_om_users (
687+ id SERIAL PRIMARY KEY,
688+ name TEXT NOT NULL,
689+ email TEXT UNIQUE NOT NULL,
690+ active BOOLEAN DEFAULT true NOT NULL,
691+ role TEXT NOT NULL
692+ )"""
693+
694+withSettingsTable :: (PG.Connection -> Aff Unit) -> Aff Unit
695+withSettingsTable test = do
696+ conn <- testConnection
697+ _ <- PG.executeSimple createDDL conn
698+ test conn
699+ _ <- PG.executeSimple dropDDL conn
700+ PG.end conn
701+ where
702+ dropDDL = PG.SQL "DROP TABLE IF EXISTS test_om_settings CASCADE"
703+ createDDL = PG.SQL
704+ """DROP TABLE IF EXISTS test_om_settings CASCADE;
705+ CREATE TABLE test_om_settings (
706+ key TEXT PRIMARY KEY,
707+ value TEXT NOT NULL
708+ )"""
709+
710+withUuidTable :: (PG.Connection -> Aff Unit) -> Aff Unit
711+withUuidTable test = do
712+ conn <- testConnection
713+ _ <- PG.executeSimple createDDL conn
714+ test conn
715+ _ <- PG.executeSimple dropDDL conn
716+ PG.end conn
717+ where
718+ dropDDL = PG.SQL "DROP TABLE IF EXISTS test_om_uuid_things CASCADE"
719+ createDDL = PG.SQL
720+ """DROP TABLE IF EXISTS test_om_uuid_things CASCADE;
721+ CREATE TABLE test_om_uuid_things (
722+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
723+ label TEXT NOT NULL
724+ )"""
725+
726+withPostsTable :: (PG.Connection -> Aff Unit) -> Aff Unit
727+withPostsTable test = do
728+ conn <- testConnection
729+ _ <- PG.executeSimple createDDL conn
730+ test conn
731+ _ <- PG.executeSimple (PG.SQL "DROP TABLE IF EXISTS test_om_posts CASCADE") conn
732+ _ <- PG.executeSimple (PG.SQL "DROP TABLE IF EXISTS test_om_users CASCADE") conn
733+ PG.end conn
734+ where
735+ createDDL = PG.SQL
736+ """DROP TABLE IF EXISTS test_om_posts CASCADE;
737+ DROP TABLE IF EXISTS test_om_users CASCADE;
738+ CREATE TABLE test_om_users (
739+ id SERIAL PRIMARY KEY,
740+ name TEXT NOT NULL,
741+ email TEXT UNIQUE NOT NULL,
742+ active BOOLEAN DEFAULT true NOT NULL,
743+ role TEXT NOT NULL
744+ );
745+ CREATE TABLE test_om_posts (
746+ id SERIAL PRIMARY KEY,
747+ title TEXT NOT NULL,
748+ body TEXT NOT NULL,
749+ user_id INTEGER NOT NULL REFERENCES test_om_users(id)
750+ )"""
751+
752+withPostsAndCommentsTable :: (PG.Connection -> Aff Unit) -> Aff Unit
753+withPostsAndCommentsTable test = do
754+ conn <- testConnection
755+ _ <- PG.executeSimple createDDL conn
756+ test conn
757+ _ <- PG.executeSimple (PG.SQL "DROP TABLE IF EXISTS test_om_comments CASCADE") conn
758+ _ <- PG.executeSimple (PG.SQL "DROP TABLE IF EXISTS test_om_posts CASCADE") conn
759+ _ <- PG.executeSimple (PG.SQL "DROP TABLE IF EXISTS test_om_users CASCADE") conn
760+ PG.end conn
761+ where
762+ createDDL = PG.SQL
763+ """DROP TABLE IF EXISTS test_om_comments CASCADE;
764+ DROP TABLE IF EXISTS test_om_posts CASCADE;
765+ DROP TABLE IF EXISTS test_om_users CASCADE;
766+ CREATE TABLE test_om_users (
767+ id SERIAL PRIMARY KEY,
768+ name TEXT NOT NULL,
769+ email TEXT UNIQUE NOT NULL,
770+ active BOOLEAN DEFAULT true NOT NULL,
771+ role TEXT NOT NULL
772+ );
773+ CREATE TABLE test_om_posts (
774+ id SERIAL PRIMARY KEY,
775+ title TEXT NOT NULL,
776+ body TEXT NOT NULL,
777+ user_id INTEGER NOT NULL REFERENCES test_om_users(id)
778+ );
779+ CREATE TABLE test_om_comments (
780+ id SERIAL PRIMARY KEY,
781+ text TEXT NOT NULL,
782+ user_id INTEGER NOT NULL REFERENCES test_om_users(id)
783+ )"""
784+
785+shouldBeJust :: forall a. Maybe a -> Aff a
786+shouldBeJust (Just a) = pure a
787+shouldBeJust Nothing = throwError $ error "Expected Just but got Nothing"
test/Test/SchemaQ.purs+63−67
@@ -17,73 +17,6 @@ import Yoga.Postgres as PG
17import Yoga.Postgres.ClientOm (run, runOne, create) as Q
17import Yoga.Postgres.ClientOm (run, runOne, create) as Q
18import Yoga.Postgres.Schema (Table, PrimaryKey, AutoIncrement, Unique, Default, from, select, where_, orderBy, limit, groupBy, insert, delete, returning, returningAll, union)
18import Yoga.Postgres.Schema (Table, PrimaryKey, AutoIncrement, Unique, Default, from, select, where_, orderBy, limit, groupBy, insert, delete, returning, returningAll, union)
19
19
20−-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
21−-- Test schema
22−-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
23−
24−type UsersTable = Table "test_om_users"
25− ( id :: PrimaryKey (AutoIncrement Int)
26− , name :: String
27− , email :: Unique String
28− , active :: Default "true" Boolean
29− , role :: String
30− )
31−
32−usersTable :: Proxy UsersTable
33−usersTable = Proxy
34−
35−-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
36−-- Helpers
37−-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
38−
39−testConnection :: Aff PG.Connection
40−testConnection =
41− PG.postgres
42− { host: PG.PostgresHost "localhost"
43− , port: PG.PostgresPort 5433
44− , database: PG.PostgresDatabase "test_playground"
45− , username: PG.PostgresUsername "postgres"
46− , password: PG.PostgresPassword "postgres"
47− } # liftEffect
48−
49−exec
50− :: forall a
51− . Om.Om { postgresConnection :: PG.Connection } (parseError :: MultipleErrors) a
52− -> PG.Connection
53− -> Aff a
54−exec om conn = Om.runOm { postgresConnection: conn }
55− { exception: \e -> throwError e
56− , parseError: \errs -> throwError (error ("Parse error: " <> show errs))
57− }
58− om
59−
60−shouldBeJust :: forall a. Maybe a -> Aff a
61−shouldBeJust (Just a) = pure a
62−shouldBeJust Nothing = throwError $ error "Expected Just but got Nothing"
63−
64−withUsersTable :: (PG.Connection -> Aff Unit) -> Aff Unit
65−withUsersTable test = do
66− conn <- testConnection
67− _ <- PG.executeSimple createDDL conn
68− test conn
69− _ <- PG.executeSimple dropDDL conn
70− PG.end conn
71− where
72− dropDDL = PG.SQL "DROP TABLE IF EXISTS test_om_users CASCADE"
73− createDDL = PG.SQL
74− """DROP TABLE IF EXISTS test_om_users CASCADE;
75− CREATE TABLE test_om_users (
76− id SERIAL PRIMARY KEY,
77− name TEXT NOT NULL,
78− email TEXT UNIQUE NOT NULL,
79− active BOOLEAN DEFAULT true NOT NULL,
80− role TEXT NOT NULL
81− )"""
82−
83−-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
84−-- Spec
85−-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
86−
87spec :: Spec Unit
20spec :: Spec Unit
88spec = describe "Query builder" do
21spec = describe "Query builder" do
89
22
@@ -148,3 +81,66 @@ spec = describe "Query builder" do
148 (from usersTable # select @"name" # where_ @"role = $b")
81 (from usersTable # select @"name" # where_ @"role = $b")
149 )
82 )
150 Array.sort (map _.name rows) `shouldEqual` [ "Alice", "Carol" ]
83 Array.sort (map _.name rows) `shouldEqual` [ "Alice", "Carol" ]
84+
85+-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
86+-- Test schema
87+-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
88+
89+type UsersTable = Table "test_om_users"
90+ ( id :: PrimaryKey (AutoIncrement Int)
91+ , name :: String
92+ , email :: Unique String
93+ , active :: Default "true" Boolean
94+ , role :: String
95+ )
96+
97+usersTable :: Proxy UsersTable
98+usersTable = Proxy
99+
100+-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
101+-- Helpers
102+-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
103+
104+testConnection :: Aff PG.Connection
105+testConnection =
106+ PG.postgres
107+ { host: PG.PostgresHost "localhost"
108+ , port: PG.PostgresPort 5433
109+ , database: PG.PostgresDatabase "test_playground"
110+ , username: PG.PostgresUsername "postgres"
111+ , password: PG.PostgresPassword "postgres"
112+ } # liftEffect
113+
114+exec
115+ :: forall a
116+ . Om.Om { postgresConnection :: PG.Connection } (parseError :: MultipleErrors) a
117+ -> PG.Connection
118+ -> Aff a
119+exec om conn = Om.runOm { postgresConnection: conn }
120+ { exception: \e -> throwError e
121+ , parseError: \errs -> throwError (error ("Parse error: " <> show errs))
122+ }
123+ om
124+
125+shouldBeJust :: forall a. Maybe a -> Aff a
126+shouldBeJust (Just a) = pure a
127+shouldBeJust Nothing = throwError $ error "Expected Just but got Nothing"
128+
129+withUsersTable :: (PG.Connection -> Aff Unit) -> Aff Unit
130+withUsersTable test = do
131+ conn <- testConnection
132+ _ <- PG.executeSimple createDDL conn
133+ test conn
134+ _ <- PG.executeSimple dropDDL conn
135+ PG.end conn
136+ where
137+ dropDDL = PG.SQL "DROP TABLE IF EXISTS test_om_users CASCADE"
138+ createDDL = PG.SQL
139+ """DROP TABLE IF EXISTS test_om_users CASCADE;
140+ CREATE TABLE test_om_users (
141+ id SERIAL PRIMARY KEY,
142+ name TEXT NOT NULL,
143+ email TEXT UNIQUE NOT NULL,
144+ active BOOLEAN DEFAULT true NOT NULL,
145+ role TEXT NOT NULL
146+ )"""