@@ -133,6 +133,17 @@ instance Category Definition where
133CREATE statements
133CREATE statements
134-----------------------------------------}
134-----------------------------------------}
137+`createSchema` enters a new schema into the current database.
138+The schema name must be distinct from the name of any existing schema
139+in the current database.
141+A schema is essentially a namespace: it contains named objects
142+(tables, data types, functions, and operators) whose names
143+can duplicate those of other objects existing in other schemas.
144+Named objects are accessed by `QualifiedAlias`es with the schema
136createSchema
147createSchema
137 :: KnownSymbol sch
148 :: KnownSymbol sch
138 => Alias sch
149 => Alias sch
@@ -140,6 +151,7 @@ createSchema
140createSchema sch = UnsafeDefinition $
151createSchema sch = UnsafeDefinition $
141 "CREATE" <+> "SCHEMA" <+> renderSQL sch <> ";"
152 "CREATE" <+> "SCHEMA" <+> renderSQL sch <> ";"
154+{- | Idempotent version of `createSchema`. -}
143createSchemaIfNotExists
155createSchemaIfNotExists
144 :: (KnownSymbol sch, Has sch schemas schema)
156 :: (KnownSymbol sch, Has sch schemas schema)
145 => Alias sch
157 => Alias sch
@@ -537,7 +549,7 @@ instance RenderSQL OnUpdateClause where
537DROP statements
549DROP statements
538-----------------------------------------}
550-----------------------------------------}
540−-- >>> :{
552+-- | >>> :{
542-- definition :: Definition '["muh_schema" ::: schema, "public" ::: public] '["public" ::: public]
554-- definition :: Definition '["muh_schema" ::: schema, "public" ::: public] '["public" ::: public]
543-- definition = dropSchema #muh_schema
555-- definition = dropSchema #muh_schema