Skip to content

Domain

Creates a user-defined data type with optional constraints.

Properties

Property Type Required Description
name string yes The name of the domain function to create.
schema string yes The schema to create the domain function in.
owner string — The role that owns the domain function.
sql string — User-provided raw SQL snippet.
data_type string — The underlying data type of the domain.
collation string — An optional collation for the domain. If no collation is specified, the underlying data type's default collation is used. The underlying type must be collatable if COLLATE is specified.
default boolean | null | number | string — The DEFAULT clause specifies a default value for columns of the domain data type. The value is any variable-free expression (but subqueries are not allowed). The data type of the default expression must match the data type of the domain. If no default value is specified, then the default value is the null value.
check_constraints array of object — An array of one or more check constraints. Entries must be unique.
comment string — An optional comment about the domain.
security_labels security_labels — Security Labels.
dependencies dependencies — Database objects this object is dependent upon.

check_constraints[]

Property Type Required Description
name string — Constraint Name.
nullable boolean — Domain is Nullable.
expression string — Constraint Expression.
not_valid boolean — true renders NOT VALID: values already in columns of the domain were never checked, only new ones are. Only a CHECK can be NOT VALID, and only ALTER DOMAIN can add it, so the build writes it that way. Absent means valid, the default.
comment string — An optional comment about the constraint.

Mutually exclusive forms

Exactly one of these must hold:

  • expression, without nullable
  • nullable, without expression

Mutually exclusive forms

Exactly one of these must hold:

  • sql, without data_type or check_constraints
  • data_type, without sql

No other properties are accepted.


Source: schemata/domain.yml · Resolved JSON Schema: domain.json