Skip to content

Schema Types

ColumnDefinition

Type: Object

Properties

  • name string The name of the column.
  • type string PostgreSQL data type (e.g., 'text', 'uuid', 'integer', 'varchar', 'jsonb').
  • generated ("always" | "by default")? Marks the column as a generated column.
  • expression string? SQL expression used for the generated column.
  • stored boolean? Whether the generated column should be stored.
  • notNull boolean? Whether the column accepts null values. Defaults to false.
  • 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 Object? Extended column behavior modifiers.

    • colProps.mod string? pg-promise format modifier.
    • colProps.cnd boolean? Use in conditional update clause.
    • colProps.def string? Override default value.
    • colProps.validator any? Custom Zod validator for this column.

ConstraintDefinition

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

Type: Object

Properties

TableSchema

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.
  • softDelete boolean? Whether to use a soft delete strategy.
  • version string? Optional schema version string.
  • columns Array<ColumnDefinition> List of column definitions.
  • constraints Constraints? Table-level constraints.