Skip to content

Schema Types

SkipFunction

Function to conditionally skip this column in update.

Type: Function

Parameters

  • col any Column value being inserted or updated

Returns boolean True to skip this column

InitFunction

Function to initialize the value dynamically.

Type: Function

Parameters

  • dto Object Data transfer object being processed

Returns any Initialized value for the column

ColumnProps

pg-promise column helper modifiers.

Type: Object

Properties

  • mod string? Format modifier.
  • skip SkipFunction? Conditionally skip this column in update.
  • cnd boolean? Use in conditional update clause.
  • init InitFunction? Initialize the value dynamically.
  • def string? Override default value.

ColumnDefinition

Defines the structure of a single column in a table schema.

Type: Object

Properties

  • name string The name of the column.
  • type string PostgreSQL data type (e.g., 'text', 'uuid', 'integer', 'varchar', 'jsonb').
  • nullable boolean? Whether the column accepts null values. Defaults to true.
  • default any? Default value for the column. Can be a literal or SQL expression.
  • immutable boolean? If true, the column cannot be updated after creation. Defaults to false.
  • colProps ColumnProps? pg-promise column helper modifiers.

ConstraintDefinition

Represents a schema-level constraint such as primary key or foreign key.

Type: Object

Properties

  • type ("PrimaryKey" | "ForeignKey" | "Unique" | "Check" | "Index") Type of constraint.
  • columns Array<string> List of column names the constraint applies to.
  • references {table: string, columns: Array<string>}? For foreign keys.
  • onDelete string? Optional ON DELETE behavior (e.g., 'CASCADE').
  • expression string? SQL expression for check constraints.

Constraints

Container for all structural and relational constraints applied to a table.

Type: Object

Properties

TableSchema

Describes the full definition of a table schema for pg-schemata.

Type: Object

Properties

  • dbSchema string PostgreSQL schema name (e.g., 'public').
  • table string Table name.
  • hasAuditFields boolean? Whether to include created_at/updated_at/by fields.
  • version string? Optional schema version string.
  • columns Array<ColumnDefinition> List of column definitions.
  • constraints Constraints? Table-level constraints.