on dev help sign in
create some schemas
463bd94Eitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+17
@@ -33,6 +33,8 @@ module Squeal.PostgreSQL.Definition
33 , (>>>)
33 , (>>>)
34 -- * Tables
34 -- * Tables
35 -- ** Create
35 -- ** Create
36+ , createSchema
37+ , createSchemaIfNotExists
36 , createTable
38 , createTable
37 , createTableIfNotExists
39 , createTableIfNotExists
38 , TableConstraintExpression (..)
40 , TableConstraintExpression (..)
@@ -125,6 +127,21 @@ instance Category Definition where
125CREATE statements
127CREATE statements
126-----------------------------------------}
128-----------------------------------------}
127
129
130+createSchema
131+ :: KnownSymbol sch
132+ => Alias sch
133+ -> Definition db (Create sch '[] db)
134+createSchema sch = UnsafeDefinition $
135+ "CREATE" <+> "SCHEMA" <+> renderAlias sch <> ";"
136+
137+createSchemaIfNotExists
138+ :: (KnownSymbol sch, Has sch db schema)
139+ => Alias sch
140+ -> Definition db db
141+createSchemaIfNotExists sch = UnsafeDefinition $
142+ "CREATE" <+> "SCHEMA" <+> "IF" <+> "NOT" <+> "EXISTS"
143+ <+> renderAlias sch <> ";"
144+
128{- | `createTable` adds a table to the schema.
145{- | `createTable` adds a table to the schema.
129
146
130>>> :set -XOverloadedLabels
147>>> :set -XOverloadedLabels