@@ -67,6 +67,8 @@ module Squeal.PostgreSQL.Definition
67 -- * Views
67 -- * Views
68 , createView
68 , createView
69 , dropView
69 , dropView
70 , createTypeEnum
72 , createTypeEnum
71 , ColumnTypeExpression (..)
73 , ColumnTypeExpression (..)
@@ -790,6 +792,15 @@ createTypeEnum enum labels = UnsafeDefinition $
790 "CREATE" <+> "TYPE" <+> renderAlias enum <+> "AS" <+>
792 "CREATE" <+> "TYPE" <+> renderAlias enum <+> "AS" <+>
791 parenthesized (commaSeparated (renderAliases labels)) <> ";"
793 parenthesized (commaSeparated (renderAliases labels)) <> ";"
796+ :: (KnownSymbol comp, SOP.SListI fields)
798+ -> NP (Aliased TypeExpression) fields
799+ -> Definition schema (Create comp ('Typedef ('PGcomposite fields)) schema)
800+createType comp fields = UnsafeDefinition $
801+ "CREATE" <+> "TYPE" <+> renderAlias comp <+> "AS" <+> parenthesized
802+ (renderCommaSeparated (renderAliasedAs renderTypeExpression) fields)
793-- | `ColumnTypeExpression`s are used in `createTable` commands.
804-- | `ColumnTypeExpression`s are used in `createTable` commands.
794newtype ColumnTypeExpression (schema :: SchemaType) (ty :: ColumnType)
805newtype ColumnTypeExpression (schema :: SchemaType) (ty :: ColumnType)
795 = UnsafeColumnTypeExpression { renderColumnTypeExpression :: ByteString }
806 = UnsafeColumnTypeExpression { renderColumnTypeExpression :: ByteString }