Syntax
CREATE TYPE
features:
- Schema-qualified names: Types can be defined in specific schemas
- ENUM types: User-defined enumeration types
- Empty enums (no values)
- Single-quoted string values
- Multiple values separated by commas
- Composite types: Row types with named attributes
- Multiple attributes with their data types
- Any valid PostgreSQL data type for attributes
- Named attributes for structured data
Canonical Format
When generating migration SQL, pgschema produces types in the following canonical format:- Uses single-line format for empty enums
- Uses multi-line format with indentation for enums with values
- Each enum value is on its own indented line for readability
- No comma after the last enum value
- Composite types use single-line format with attributes separated by commas
- For DROP operations:
DROP TYPE IF EXISTS type_name RESTRICT;
- ENUM types can be modified by adding values with
ALTER TYPE type_name ADD VALUE 'new_value' AFTER 'existing_value';