on dev help sign in
create some schemas
commit463bd94781527f3685a07a0de023aaa4a5def497 authorEitan Chatav <eitan.chatav@gmail.com> dateSat 24 Nov 2018, 16:39 (8 years ago) parentdd96a8b
1 file changed+17
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+17
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+17
@@ -33,6 +33,8 @@ module Squeal.PostgreSQL.Definition
3333 , (>>>)
3434 -- * Tables
3535 -- ** Create
36+ , createSchema
37+ , createSchemaIfNotExists
3638 , createTable
3739 , createTableIfNotExists
3840 , TableConstraintExpression (..)
@@ -125,6 +127,21 @@ instance Category Definition where
125127CREATE statements
126128-----------------------------------------}
127129
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+
128145{- | `createTable` adds a table to the schema.
129146
130147>>> :set -XOverloadedLabels