Skip to content

Domain Operations ​

Operation: createDomain ​

pgm.createDomain( domain_name, type, options ) ​

IMPORTANT

Create a new domain - postgres docs

Arguments ​

NameTypeDescription
domain_nameNameName of the new domain
typestringType of the new domain
optionsobjectCheck below for available options

Options ​

OptionTypeDescription
defaultstringDefault value of domain
collationstringCollation of data type
notNullbooleanSets NOT NULL if true (not recommended)
checkstringSQL for a check constraint for this column
constraintNamestringName for constraint

Reverse Operation: dropDomain ​

pgm.dropDomain( domain_name, drop_options ) ​

IMPORTANT

Drop a domain - postgres docs

Arguments ​

NameTypeDescription
domain_nameNameName of the domain to drop
drop_optionsobjectCheck below for available options

Options ​

OptionTypeDescription
ifExistsbooleanDrops domain only if it exists
cascadebooleanDrops also dependent objects

Operation: alterDomain ​

pgm.alterDomain( domain_name, type, options ) ​

IMPORTANT

Alter a domain - postgres docs

Arguments ​

NameTypeDescription
domain_nameNameName of the new domain
optionsobjectCheck below for available options

Options ​

OptionTypeDescription
defaultstringDefault value of domain
collationstringCollation of data type
notNullbooleansets NOT NULL if true or NULL if false
allowNullbooleansets NULL if true (alternative to notNull)
checkstringsql for a check constraint for this column
constraintNamestringname for constraint

Operation: renameDomain ​

pgm.renameDomain( old_domain_name, new_domain_name ) ​

IMPORTANT

Rename a domain - postgres docs

Arguments ​

NameTypeDescription
old_domain_nameNameOld name of the domain
new_domain_nameNameNew name of the domain

Renaming preserves the source schema, including during automatic reversal. See Renaming and schemas for destination-schema validation and supported PgLiteral identifiers.

To move a domain between schemas, use SQL explicitly, for example pgm.sql('ALTER DOMAIN "old_schema"."my_domain" SET SCHEMA "new_schema"'). Provide the corresponding SQL in your down migration to reverse that move.