Skip to main content

PostgreSQL Schema

aggregate​

aggregate attributes​

NameRequiredValue
commentfalsestring
depends_onfalse

List of object references

initial_valuefalse

Aggregate initial value can be one of:

  1. bool
  2. string
  3. number
  4. Raw expression defined with sql("expr")
parallelfalse

enum (SAFE, UNSAFE, RESTRICTED)

schematrue

Object reference to schema

state_functrue

Aggregate state function can be one of:

  1. Object reference to function
  2. enum (numeric_add, numeric_mul, numeric_avg_accum, numeric_avg, numeric_avg_serialize, numeric_avg_deserialize, numeric_avg_combine, numeric_smaller, numeric_larger, int4pl, int4_avg_accum, int8inc, int8inc_any, int8_avg, int8pl, int8mi, int2pl, int2mi, int4larger, int4smaller, int8larger, int8smaller, float4pl, float4mi, float8pl, float8mi, float4mul, float8mul, float4larger, float4smaller, float8larger, float8smaller, ordered_set_transition, ordered_set_transition_multi, percentile_disc_final, percentile_cont_final, rank_final, dense_rank_final, percent_rank_final, cume_dist_final, array_agg_transfn, array_agg_finalfn, textcat, text_larger, text_smaller, booland_statefunc, boolor_statefunc, booland_statefunc_inv, boolor_statefunc_inv, bitand, bitor, bitxor, point_add, point_sub, json_agg_transfn, json_agg_finalfn, jsonb_agg_transfn, jsonb_agg_finalfn)
  3. string
state_typetrue

Aggregate state type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
  3. Object reference to enum
  4. Object reference to range
  5. Object reference to domain
  6. Object reference to composite
  7. Object reference to table
  8. Object reference to view

aggregate blocks​

aggregate.arg​

aggregate.arg attributes​
NameRequiredValue
defaultfalse

Aggregate argument default value can be one of:

  1. bool
  2. string
  3. number
  4. Raw expression defined with sql("expr")
modefalse

Aggregate argument mode can be one of:

  1. string
  2. enum (IN, OUT, INOUT, VARIADIC)
typetrue

Aggregate argument type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
  3. Object reference to enum
  4. Object reference to range
  5. Object reference to domain
  6. Object reference to composite
  7. Object reference to table
  8. Object reference to view
aggregate.arg constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

aggregate constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., aggregate "name" )true
Allow Qualifier (e.g., aggregate "schema" "name" )true
Repeatabletrue

cast​

The cast block describes a type cast in the database.

# Binary coercion cast (WITHOUT FUNCTION)
cast {
source = text
target = composite.my_type
}

# I/O conversion cast (WITH INOUT)
cast {
source = int4
target = composite.my_type
with = INOUT
}

# Function-based cast (WITH FUNCTION)
cast {
source = int4
target = composite.my_type
with = function.int4_to_my_type
as = IMPLICIT
}

cast attributes​

NameRequiredValue
asfalse

enum (ASSIGNMENT, IMPLICIT)

sourcetrue

Cast source type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
  3. Object reference to enum
  4. Object reference to range
  5. Object reference to domain
  6. Object reference to composite
  7. Object reference to table
  8. Object reference to view
targettrue

Cast target type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
  3. Object reference to enum
  4. Object reference to range
  5. Object reference to domain
  6. Object reference to composite
  7. Object reference to table
  8. Object reference to view
withfalse

Cast method (INOUT, function reference, or function expression) can be one of:

  1. enum (INOUT)
  2. Object reference to function
  3. Raw expression defined with sql("expr")
  4. string

cast constraints​

ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

collation​

The collation block describes a collation in the schema.

collation "french" {
schema = schema.public
locale = "fr-x-icu"
provider = icu
}

collation "german" {
schema = schema.public
from = "german_phonebook"
}

collation attributes​

NameRequiredValue
commentfalsestring
deterministicfalsebool
lc_collatefalsestring
lc_ctypefalsestring
localefalsestring
namefalsestring
providerfalse

Collation provider can be one of:

  1. string
  2. enum (libc, icu, builtin)
rulesfalsestring
schematrue

Object reference to schema

versionfalsestring

collation constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., collation "name" )true
Allow Qualifier (e.g., collation "schema" "name" )true

composite​

The composite block describes a composite type in the schema.

composite "address" {
schema = schema.public
field "street" {
type = text
}
field "city" {
type = text
}
}

composite attributes​

NameRequiredValue
commentfalsestring
namefalsestring
schematrue

Object reference to schema

composite blocks​

composite.field​

composite.field attributes​
NameRequiredValue
collatefalse

Field collation can be one of:

  1. string
  2. Object reference to collation
typetrue

Field type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
  3. Object reference to enum
  4. Object reference to range
  5. Object reference to domain
  6. Object reference to composite
  7. Object reference to table
  8. Object reference to view
composite.field constraints​
ConstraintValue
Requiredtrue
Require Name (e.g., composite.field "name" )true

composite constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., composite "name" )true
Allow Qualifier (e.g., composite "schema" "name" )true

data​

The data block defines seed/lookup data for a table.

data {
table = table.countries
rows = [
{ code = "US", name = "United States" },
{ code = "CA", name = "Canada" },
]
}

data attributes​

NameRequiredValue
rowstrue

Any value

tabletrue

Object reference to table

data constraints​

ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

domain​

The domain block describes a DOMAIN type in the schema.

domain "us_postal_code" {
schema = schema.public
type = text
null = true
check "us_postal_code_check" {
expr = "..."
}
}

domain attributes​

NameRequiredValue
commentfalsestring
defaultfalse

Domain default value can be one of:

  1. bool
  2. string
  3. number
  4. Raw expression defined with sql("expr")
namefalsestring
nullfalsebool
schematrue

Object reference to schema

typetrue

Domain type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
  3. Object reference to enum
  4. Object reference to range
  5. Object reference to domain
  6. Object reference to composite
  7. Object reference to table
  8. Object reference to view

domain blocks​

domain.check​

domain.check attributes​
NameRequiredValue
commentfalsestring
exprtruestring
domain.check constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

domain constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., domain "name" )true
Allow Qualifier (e.g., domain "schema" "name" )true

enum​

The enum block describes an ENUM type in the schema.

enum "status" {
schema = schema.test
values = ["on", "off"]
}

enum attributes​

NameRequiredValue
commentfalsestring
namefalsestring
schematrue

Object reference to schema

valuestrue

List of strings

enum constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., enum "name" )true
Allow Qualifier (e.g., enum "schema" "name" )true

event_trigger​

The event_trigger block describes an event trigger in the database.

event_trigger "record_table_creation" {
on = ddl_command_start
tags = ["CREATE TABLE"]
execute = function.record_table_creation
}

event_trigger attributes​

NameRequiredValue
commentfalsestring
executetrue

Object reference to function

ontrue

Event trigger on can be one of:

  1. string
  2. enum (ddl_command_start, ddl_command_end, table_rewrite, sql_drop)
tagsfalse

List of strings

event_trigger constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., event_trigger "name" )true

extension​

The extension block describes an extension in the database.

extension "postgis" {
schema = schema.public
}
extension "pgcrypto" {
schema = schema.public
version = "1.3"
comment = "cryptographic functions"
}

extension attributes​

Name and descriptionRequiredValue
commentfalsestring

depends_on

The depends_on attribute specifies the extensions that this extension depends on.

false

List of object reference to extension

namefalsestring
schemafalse

Object reference to schema

versionfalsestring

extension constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., extension "name" )true

foreign_table​

foreign_table attributes​

NameRequiredValue
commentfalsestring
depends_onfalse

List of object references

optionsfalsemap
replica_identityfalse

enum (NOTHING)

schematrue

Object reference to schema

servertrue

The reference or a name of an existing foreign server to use for the foreign table can be one of:

  1. Object reference to server
  2. string

foreign_table blocks​

foreign_table.check​

foreign_table.check attributes​
NameRequiredValue
commentfalsestring
exprtruestring
foreign_table.check constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

foreign_table.column​

foreign_table.column attributes​
NameRequiredValue
asfalsestring
collatefalse

Column collation can be one of:

  1. string
  2. Object reference to collation
commentfalsestring
nullfalsebool
optionsfalsemap
typetrue

Column type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
  3. Object reference to enum
  4. Object reference to range
  5. Object reference to domain
  6. Object reference to composite
  7. Object reference to table
  8. Object reference to view
foreign_table.column blocks​

foreign_table.column.annotation​

foreign_table.column.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue

foreign_table.column.as​

foreign_table.column.as attributes​
NameRequiredValue
exprtruestring
typefalse

enum (STORED, VIRTUAL)

foreign_table.column constraints​
ConstraintValue
Requiredfalse
Require Name (e.g., foreign_table.column "name" )true
Mutually exclusive sets[as (attribute), as (block)]

foreign_table constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., foreign_table "name" )true
Allow Qualifier (e.g., foreign_table "schema" "name" )true

function​

The function block describes a function in a database schema.

function "positive" {
schema = schema.public
lang = SQL
arg "v" {
type = integer
}
...
}

function attributes​

NameRequiredValue
astruestring
commentfalsestring
depends_onfalse

List of object references

langtrue

Function language can be one of:

  1. string
  2. enum (SQL, PLpgSQL)
leakprooffalsebool
parallelfalse

enum (SAFE, UNSAFE, RESTRICTED)

returnfalse

Function return type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
  3. Object reference to enum
  4. Object reference to range
  5. Object reference to domain
  6. Object reference to composite
  7. Object reference to table
  8. Object reference to view
return_setfalse

Function return_set type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
  3. Object reference to enum
  4. Object reference to range
  5. Object reference to domain
  6. Object reference to composite
  7. Object reference to table
  8. Object reference to view
rowsfalseint
schematrue

Object reference to schema

securityfalse

enum (DEFINER, INVOKER)

strictfalsebool
volatilityfalse

enum (VOLATILE, STABLE, IMMUTABLE)

function blocks​

function.annotation​

function.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue

function.arg​

function.arg attributes​
NameRequiredValue
defaultfalse

Function argument default value can be one of:

  1. bool
  2. string
  3. number
  4. Raw expression defined with sql("expr")
modefalse

Function argument mode can be one of:

  1. string
  2. enum (IN, OUT, INOUT, VARIADIC)
typetrue

Function argument type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
  3. Object reference to enum
  4. Object reference to range
  5. Object reference to domain
  6. Object reference to composite
  7. Object reference to table
  8. Object reference to view
function.arg constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

function.config_params​

The config_params block describes the configuration parameters to be set when the function is entered.

config_params {
search_path = "public"
work_mem = "64MB"
client_min_messages = "warning"
// Other custom configuration parameters.
}
function.config_params attributes​
NameRequiredValue
schemafalsestring
search_pathfalsestring
statement_timeoutfalsestring
work_memfalsestring
function.config_params constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown attributestrue

function.return_table​

function.return_table blocks​

function.return_table.column​

function.return_table.column attributes​
NameRequiredValue
typetrue

Function return_table column type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
  3. Object reference to enum
  4. Object reference to range
  5. Object reference to domain
  6. Object reference to composite
  7. Object reference to table
  8. Object reference to view
function.return_table.column blocks​

function.return_table.column.annotation​

function.return_table.column.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue
function.return_table.column constraints​
ConstraintValue
Requiredtrue
Require Name (e.g., function.return_table.column "name" )true

function constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., function "name" )true
Allow Qualifier (e.g., function "schema" "name" )true
Repeatabletrue
Mutually exclusive sets[return, return_set, return_table]

materialized​

The materialized block describes a materialized view in a database schema.

materialized "name" {
schema = schema.public
column "total" {
null = true
type = numeric
}
...
}

materialized attributes​

NameRequiredValue
astruestring
commentfalsestring
depends_onfalse

List of object references

schematrue

Object reference to schema

materialized blocks​

materialized.annotation​

materialized.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue

materialized.column​

materialized.column attributes​
NameRequiredValue
commentfalsestring
nullfalsebool
typetrue

Column type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
  3. Object reference to enum
  4. Object reference to range
  5. Object reference to domain
  6. Object reference to composite
  7. Object reference to table
  8. Object reference to view
materialized.column blocks​

materialized.column.annotation​

materialized.column.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue
materialized.column constraints​
ConstraintValue
Requiredfalse
Require Name (e.g., materialized.column "name" )true

materialized.index​

materialized.index attributes​
NameRequiredValue
columnsfalse

Index columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
commentfalsestring
includefalse

Index included columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
nulls_distinctfalsebool
page_per_rangefalseint
renamed_fromfalsestring
typefalse

Index key type can be one of:

  1. string
  2. enum (BTREE, BRIN, HASH, GIN, GIST, GiST, SPGIST, SPGiST)
uniquefalsebool
wherefalsestring
materialized.index blocks​

materialized.index.on​

materialized.index.on attributes​
NameRequiredValue
columnfalse

Index columns can be one of:

  1. Object reference to column
  2. Object reference to table.column
descfalsebool
exprfalsestring
nulls_firstfalsebool
nulls_lastfalsebool
opsfalse

Index operator class can be one of:

  1. string
  2. Raw expression defined with sql("expr")
  3. enum (bit_minmax_ops, box_inclusion_ops, bpchar_bloom_ops, bpchar_minmax_ops, bytea_bloom_ops, bytea_minmax_ops, char_bloom_ops, char_minmax_ops, date_bloom_ops, date_minmax_multi_ops, date_minmax_ops, float4_bloom_ops, float4_minmax_multi_ops, float4_minmax_ops, float8_bloom_ops, float8_minmax_multi_ops, float8_minmax_ops, inet_bloom_ops, inet_inclusion_ops, inet_minmax_multi_ops, inet_minmax_ops, int2_bloom_ops, int2_minmax_multi_ops, int2_minmax_ops, int4_bloom_ops, int4_minmax_multi_ops, int4_minmax_ops, int8_bloom_ops, int8_minmax_multi_ops, int8_minmax_ops, interval_bloom_ops, interval_minmax_multi_ops, interval_minmax_ops, macaddr8_bloom_ops, macaddr8_minmax_multi_ops, macaddr8_minmax_ops, macaddr_bloom_ops, macaddr_minmax_multi_ops, macaddr_minmax_ops, name_bloom_ops, name_minmax_ops, numeric_bloom_ops, numeric_minmax_multi_ops, numeric_minmax_ops, oid_bloom_ops, oid_minmax_multi_ops, oid_minmax_ops, pg_lsn_bloom_ops, pg_lsn_minmax_multi_ops, pg_lsn_minmax_ops, range_inclusion_ops, text_bloom_ops, text_minmax_ops, tid_bloom_ops, tid_minmax_multi_ops, tid_minmax_ops, time_bloom_ops, time_minmax_multi_ops, time_minmax_ops, timestamp_bloom_ops, timestamp_minmax_multi_ops, timestamp_minmax_ops, timestamptz_bloom_ops, timestamptz_minmax_multi_ops, timestamptz_minmax_ops, timetz_bloom_ops, timetz_minmax_multi_ops, timetz_minmax_ops, uuid_bloom_ops, uuid_minmax_multi_ops, uuid_minmax_ops, varbit_minmax_ops, array_ops, bit_ops, bool_ops, bpchar_ops, bpchar_pattern_ops, bytea_ops, char_ops, cidr_ops, date_ops, enum_ops, float4_ops, float8_ops, inet_ops, int2_ops, int4_ops, int8_ops, interval_ops, jsonb_ops, macaddr8_ops, macaddr_ops, money_ops, multirange_ops, name_ops, numeric_ops, oid_ops, oidvector_ops, pg_lsn_ops, range_ops, record_image_ops, record_ops, text_ops, text_pattern_ops, tid_ops, time_ops, timestamp_ops, timestamptz_ops, timetz_ops, tsquery_ops, tsvector_ops, uuid_ops, varbit_ops, varchar_ops, varchar_pattern_ops, xid8_ops, array_ops, jsonb_ops, jsonb_path_ops, tsvector_ops, box_ops, circle_ops, inet_ops, multirange_ops, point_ops, poly_ops, range_ops, tsquery_ops, tsvector_ops, aclitem_ops, array_ops, bool_ops, bpchar_ops, bpchar_pattern_ops, bytea_ops, char_ops, cid_ops, cidr_ops, date_ops, enum_ops, float4_ops, float8_ops, inet_ops, int2_ops, int4_ops, int8_ops, interval_ops, jsonb_ops, macaddr8_ops, macaddr_ops, multirange_ops, name_ops, numeric_ops, oid_ops, oidvector_ops, pg_lsn_ops, range_ops, record_ops, text_ops, text_pattern_ops, tid_ops, time_ops, timestamp_ops, timestamptz_ops, timetz_ops, uuid_ops, varchar_ops, varchar_pattern_ops, xid8_ops, xid_ops, box_ops, inet_ops, kd_point_ops, poly_ops, quad_point_ops, range_ops, text_ops, gin_trgm_ops, gist_trgm_ops, btree_geography_ops, btree_geometry_ops, gist_geography_ops, gist_geometry_ops_2d, gist_geometry_ops_nd, gist_geometry_ops_3d, hash_geometry_ops, brin_geography_inclusion_ops, brin_geometry_inclusion_ops_2d, brin_geometry_inclusion_ops_3d, brin_geometry_inclusion_ops_4d, spgist_geography_ops_nd, spgist_geometry_ops_2d, spgist_geometry_ops_3d, spgist_geometry_ops_nd)
materialized.index.on constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Mutually exclusive sets[column, expr], [nulls_last, nulls_first]

materialized.index.storage_params​

materialized.index.storage_params attributes​
NameRequiredValue
autosummarizefalsebool
bufferingfalse

enum (ON, OFF, AUTO)

deduplicate_itemsfalsebool
fastupdatefalsebool
fillfactorfalseint
gin_pending_list_limitfalseint
pages_per_rangefalseint
materialized.index.storage_params constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown attributestrue
materialized.index constraints​
ConstraintValue
Requiredfalse
Require Name (e.g., materialized.index "name" )true
Mutually exclusive sets[columns, on], [page_per_range, storage_params]
One of required sets[columns, on]

materialized constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., materialized "name" )true
Allow Qualifier (e.g., materialized "schema" "name" )true

partition​

The partition block describes a partition in the schema.

partition "cities_partition" {
of = table.cities
}

partition "cities_1000_to_100000" {
of = table.cities
range {
from = [1000]
to = [100000]
}
}

partition "orders_p1" {
of = table.orders
with {
modules = 4
remainder = 0
}
}

partition attributes​

NameRequiredValue
commentfalsestring
namefalsestring
oftrue

Parent table can be one of:

  1. Object reference to table
  2. Object reference to partition
replica_identityfalse

Replica identity for logical replication can be one of:

  1. enum (DEFAULT, NOTHING, FULL)
  2. Object reference to index
schematrue

Object reference to schema

partition blocks​

partition.check​

partition.check attributes​
NameRequiredValue
commentfalsestring
exprtruestring
partition.check constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

partition.column​

partition.column attributes​
NameRequiredValue
commentfalsestring
defaultfalse

Column default value can be one of:

  1. bool
  2. string
  3. number
  4. Raw expression defined with sql("expr")
nullfalsebool
typetrue

Column type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
  3. Object reference to enum
  4. Object reference to range
  5. Object reference to domain
  6. Object reference to composite
  7. Object reference to table
  8. Object reference to view
partition.column blocks​

partition.column.annotation​

partition.column.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue
partition.column constraints​
ConstraintValue
Requiredfalse
Require Name (e.g., partition.column "name" )true

partition.foreign_key​

partition.foreign_key attributes​
NameRequiredValue
columnstrue

Foreign key columns can be one of:

  1. List of object reference to column
commentfalsestring
deferrablefalse

enum (INITIALLY_IMMEDIATE, INITIALLY_DEFERRED)

on_deletefalse

enum (NO_ACTION, RESTRICT, CASCADE, SET_NULL, SET_DEFAULT)

on_updatefalse

enum (NO_ACTION, RESTRICT, CASCADE, SET_NULL, SET_DEFAULT)

ref_columnstrue

Foreign key reference columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
partition.foreign_key constraints​
ConstraintValue
Requiredfalse
Require Name (e.g., partition.foreign_key "name" )true

partition.hash​

partition.hash attributes​
NameRequiredValue
modulustrueint
remaindertrueint

partition.index​

partition.index attributes​
Name and descriptionRequiredValue

attached_to

The index on a partitioned table to which this index is attached.

partition "cities_1000_to_100000" {
of = table.cities
...
index "cities_1000_to_100000_idx" {
columns = [column.population]
attached_to = table.cities.index.population_idx
}
}
false

Object reference to table.index

columnsfalse

Index columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
commentfalsestring
includefalse

Index included columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
nulls_distinctfalsebool
page_per_rangefalseint
renamed_fromfalsestring
typefalse

Index key type can be one of:

  1. string
  2. enum (BTREE, BRIN, HASH, GIN, GIST, GiST, SPGIST, SPGiST)
uniquefalsebool
wherefalsestring
partition.index blocks​

partition.index.on​

partition.index.on attributes​
NameRequiredValue
columnfalse

Index columns can be one of:

  1. Object reference to column
  2. Object reference to table.column
descfalsebool
exprfalsestring
nulls_firstfalsebool
nulls_lastfalsebool
opsfalse

Index operator class can be one of:

  1. string
  2. Raw expression defined with sql("expr")
  3. enum (bit_minmax_ops, box_inclusion_ops, bpchar_bloom_ops, bpchar_minmax_ops, bytea_bloom_ops, bytea_minmax_ops, char_bloom_ops, char_minmax_ops, date_bloom_ops, date_minmax_multi_ops, date_minmax_ops, float4_bloom_ops, float4_minmax_multi_ops, float4_minmax_ops, float8_bloom_ops, float8_minmax_multi_ops, float8_minmax_ops, inet_bloom_ops, inet_inclusion_ops, inet_minmax_multi_ops, inet_minmax_ops, int2_bloom_ops, int2_minmax_multi_ops, int2_minmax_ops, int4_bloom_ops, int4_minmax_multi_ops, int4_minmax_ops, int8_bloom_ops, int8_minmax_multi_ops, int8_minmax_ops, interval_bloom_ops, interval_minmax_multi_ops, interval_minmax_ops, macaddr8_bloom_ops, macaddr8_minmax_multi_ops, macaddr8_minmax_ops, macaddr_bloom_ops, macaddr_minmax_multi_ops, macaddr_minmax_ops, name_bloom_ops, name_minmax_ops, numeric_bloom_ops, numeric_minmax_multi_ops, numeric_minmax_ops, oid_bloom_ops, oid_minmax_multi_ops, oid_minmax_ops, pg_lsn_bloom_ops, pg_lsn_minmax_multi_ops, pg_lsn_minmax_ops, range_inclusion_ops, text_bloom_ops, text_minmax_ops, tid_bloom_ops, tid_minmax_multi_ops, tid_minmax_ops, time_bloom_ops, time_minmax_multi_ops, time_minmax_ops, timestamp_bloom_ops, timestamp_minmax_multi_ops, timestamp_minmax_ops, timestamptz_bloom_ops, timestamptz_minmax_multi_ops, timestamptz_minmax_ops, timetz_bloom_ops, timetz_minmax_multi_ops, timetz_minmax_ops, uuid_bloom_ops, uuid_minmax_multi_ops, uuid_minmax_ops, varbit_minmax_ops, array_ops, bit_ops, bool_ops, bpchar_ops, bpchar_pattern_ops, bytea_ops, char_ops, cidr_ops, date_ops, enum_ops, float4_ops, float8_ops, inet_ops, int2_ops, int4_ops, int8_ops, interval_ops, jsonb_ops, macaddr8_ops, macaddr_ops, money_ops, multirange_ops, name_ops, numeric_ops, oid_ops, oidvector_ops, pg_lsn_ops, range_ops, record_image_ops, record_ops, text_ops, text_pattern_ops, tid_ops, time_ops, timestamp_ops, timestamptz_ops, timetz_ops, tsquery_ops, tsvector_ops, uuid_ops, varbit_ops, varchar_ops, varchar_pattern_ops, xid8_ops, array_ops, jsonb_ops, jsonb_path_ops, tsvector_ops, box_ops, circle_ops, inet_ops, multirange_ops, point_ops, poly_ops, range_ops, tsquery_ops, tsvector_ops, aclitem_ops, array_ops, bool_ops, bpchar_ops, bpchar_pattern_ops, bytea_ops, char_ops, cid_ops, cidr_ops, date_ops, enum_ops, float4_ops, float8_ops, inet_ops, int2_ops, int4_ops, int8_ops, interval_ops, jsonb_ops, macaddr8_ops, macaddr_ops, multirange_ops, name_ops, numeric_ops, oid_ops, oidvector_ops, pg_lsn_ops, range_ops, record_ops, text_ops, text_pattern_ops, tid_ops, time_ops, timestamp_ops, timestamptz_ops, timetz_ops, uuid_ops, varchar_ops, varchar_pattern_ops, xid8_ops, xid_ops, box_ops, inet_ops, kd_point_ops, poly_ops, quad_point_ops, range_ops, text_ops, gin_trgm_ops, gist_trgm_ops, btree_geography_ops, btree_geometry_ops, gist_geography_ops, gist_geometry_ops_2d, gist_geometry_ops_nd, gist_geometry_ops_3d, hash_geometry_ops, brin_geography_inclusion_ops, brin_geometry_inclusion_ops_2d, brin_geometry_inclusion_ops_3d, brin_geometry_inclusion_ops_4d, spgist_geography_ops_nd, spgist_geometry_ops_2d, spgist_geometry_ops_3d, spgist_geometry_ops_nd)
partition.index.on constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Mutually exclusive sets[column, expr], [nulls_last, nulls_first]

partition.index.storage_params​

partition.index.storage_params attributes​
NameRequiredValue
autosummarizefalsebool
bufferingfalse

enum (ON, OFF, AUTO)

deduplicate_itemsfalsebool
fastupdatefalsebool
fillfactorfalseint
gin_pending_list_limitfalseint
pages_per_rangefalseint
partition.index.storage_params constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown attributestrue
partition.index constraints​
ConstraintValue
Requiredfalse
Require Name (e.g., partition.index "name" )true
Mutually exclusive sets[columns, on], [page_per_range, storage_params]
One of required sets[columns, on]

partition.list​

partition.list attributes​
NameRequiredValue
intrue

List of strings

partition.partition​

partition.partition attributes​
NameRequiredValue
columnsfalse

Partition columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
typetrue

enum (RANGE, LIST, HASH)

partition.partition blocks​

partition.partition.by​

partition.partition.by attributes​
NameRequiredValue
columnfalse

Partition columns can be one of:

  1. Object reference to column
  2. Object reference to table.column
exprfalsestring
partition.partition.by constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Mutually exclusive sets[column, expr]

partition.primary_key​

partition.primary_key attributes​
NameRequiredValue
columnstrue

Primary key columns can be one of:

  1. List of object reference to column
commentfalsestring
deferrablefalse

enum (INITIALLY_IMMEDIATE, INITIALLY_DEFERRED)

includefalse

Primary key included columns can be one of:

  1. List of object reference to column
page_per_rangefalseint
typefalse

Index key type can be one of:

  1. string
  2. enum (BTREE, BRIN, HASH, GIN, GIST, GiST, SPGIST, SPGiST)
without_overlapsfalsebool
partition.primary_key blocks​

partition.primary_key.storage_params​

partition.primary_key.storage_params attributes​
NameRequiredValue
autosummarizefalsebool
bufferingfalse

enum (ON, OFF, AUTO)

deduplicate_itemsfalsebool
fastupdatefalsebool
fillfactorfalseint
gin_pending_list_limitfalseint
pages_per_rangefalseint
partition.primary_key.storage_params constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown attributestrue
partition.primary_key constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[page_per_range, storage_params]

partition.range​

partition.range attributes​
NameRequiredValue
fromtrue

List of strings

totrue

List of strings

partition.storage_params​

partition.storage_params attributes​
NameRequiredValue
autovacuum_analyze_scale_factorfalsenumber
autovacuum_analyze_thresholdfalseint
autovacuum_enabledfalsebool
autovacuum_freeze_max_agefalseint
autovacuum_freeze_min_agefalseint
autovacuum_freeze_table_agefalseint
autovacuum_multixact_freeze_max_agefalseint
autovacuum_multixact_freeze_min_agefalseint
autovacuum_multixact_freeze_table_agefalseint
autovacuum_vacuum_cost_delayfalsenumber
autovacuum_vacuum_cost_limitfalseint
autovacuum_vacuum_insert_scale_factorfalsenumber
autovacuum_vacuum_insert_thresholdfalseint
autovacuum_vacuum_max_thresholdfalseint
autovacuum_vacuum_scale_factorfalsenumber
autovacuum_vacuum_thresholdfalseint
fillfactorfalseint
log_autovacuum_min_durationfalseint
parallel_workersfalseint
toast_tuple_targetfalseint
user_catalog_tablefalsebool
vacuum_index_cleanupfalse

enum (ON, OFF, AUTO)

vacuum_max_eager_freeze_failure_ratefalsenumber
vacuum_truncatefalsebool
partition.storage_params constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown attributestrue

partition constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., partition "name" )true
Allow Qualifier (e.g., partition "schema" "name" )true
Repeatabletrue
Mutually exclusive sets[hash, range, list]

permission​

The permission block describes permissions (privileges) granted on database objects.

permission {
to = "app_user"
for = table.users
privileges = [SELECT]
}

permission {
to = role.admin
for = schema.public
privileges = [ALL]
grantable = true
}

permission {
to = PUBLIC
for = table.users
privileges = [SELECT]
}

permission attributes​

NameRequiredValue
fortrue

Permission target resource can be one of:

  1. Object reference to schema
  2. Object reference to table
  3. Object reference to view
  4. Object reference to materialized
  5. Object reference to function
  6. Object reference to procedure
  7. Object reference to sequence
  8. Object reference to partition
  9. Object reference to foreign_table
  10. Object reference to table.column
  11. Object reference to view.column
  12. Object reference to materialized.column
  13. Object reference to partition.column
  14. Object reference to foreign_table.column
grantablefalsebool
privilegestrue

List of strings or/and enums (SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER, CREATE, CONNECT, TEMPORARY, EXECUTE, USAGE, SET, ALTER_SYSTEM, MAINTAIN, ALL)

totrue

Permission grantee can be one of:

  1. enum (PUBLIC)
  2. string
  3. Object reference to role
  4. Object reference to user

permission constraints​

ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

policy​

The policy block describes a row-level security policy for a table.

policy "policy_name" {
on = table.users
for = UPDATE
to = [PUBLIC]
check = "(name = ( SELECT name FROM allowed_names))"
}

policy attributes​

NameRequiredValue
asfalse

enum (PERMISSIVE, RESTRICTIVE)

checkfalsestring
commentfalsestring
forfalse

enum (ALL, SELECT, INSERT, UPDATE, DELETE)

ontrue

Object reference to table

tofalse

List of strings or/and enums (PUBLIC, CURRENT_ROLE, CURRENT_USER, SESSION_USER)

usingfalsestring

policy constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., policy "name" )true
Repeatabletrue

procedure​

The procedure block describes a procedure in a database schema.

procedure "proc" {
schema = schema.public
lang = SQL
arg "a" {
type = integer
}
...
}

procedure attributes​

NameRequiredValue
astruestring
commentfalsestring
depends_onfalse

List of object references

langtrue

Procedure language can be one of:

  1. string
  2. enum (SQL, PLpgSQL)
schematrue

Object reference to schema

securityfalse

enum (DEFINER, INVOKER)

procedure blocks​

procedure.annotation​

procedure.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue

procedure.arg​

procedure.arg attributes​
NameRequiredValue
defaultfalse

Procedure argument default value can be one of:

  1. bool
  2. string
  3. number
  4. Raw expression defined with sql("expr")
modefalse

Procedure argument mode can be one of:

  1. string
  2. enum (IN, OUT, INOUT, VARIADIC)
typetrue

Procedure argument type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
  3. Object reference to enum
  4. Object reference to range
  5. Object reference to domain
  6. Object reference to composite
  7. Object reference to table
  8. Object reference to view
procedure.arg constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

procedure.config_params​

The config_params block describes the configuration parameters to be set when the procedure is entered.

config_params {
search_path = "public"
work_mem = "64MB"
client_min_messages = "warning"
// Other custom configuration parameters.
}
procedure.config_params attributes​
NameRequiredValue
schemafalsestring
search_pathfalsestring
statement_timeoutfalsestring
work_memfalsestring
procedure.config_params constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown attributestrue

procedure constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., procedure "name" )true
Allow Qualifier (e.g., procedure "schema" "name" )true
Repeatabletrue

range​

The range block describes a range type in the schema.

range "time_range" {
schema = schema.public
subtype = time
subtype_diff = function.time_diff
multirange_name = "multirange_name"
}

range attributes​

NameRequiredValue
commentfalsestring
multirange_namefalsestring
namefalsestring
schematrue

Object reference to schema

subtypetrue

Range subtype can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
  3. Object reference to enum
  4. Object reference to range
  5. Object reference to domain
  6. Object reference to composite
  7. Object reference to table
  8. Object reference to view
subtype_difffalse

Range subtype difference function can be one of:

  1. Object reference to function
  2. string

range constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., range "name" )true
Allow Qualifier (e.g., range "schema" "name" )true

role​

The role block describes a database role.

role "admin" {
superuser = true
create_db = true
create_role = true
member_of = [role.dba]
comment = "Administrator role"
}

role attributes​

NameRequiredValue
bypass_rlsfalsebool
commentfalsestring
conn_limitfalseint
create_dbfalsebool
create_rolefalsebool
externalfalsebool
inheritfalsebool
loginfalsebool
member_offalse

List of object reference to role

namefalsestring
replicationfalsebool
superuserfalsebool

role blocks​

role.membership​

The membership block describes a membership in a role, along with its options.

user "vault" {
membership {
role = role.reader
admin = true
}
}
role.membership attributes​
NameRequiredValue
adminfalsebool
inheritfalsebool
roletrue

Object reference to role

setfalsebool
role.membership constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

role constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., role "name" )true

schema​

The schema block describes a database schema.

schema "public" {
...
}

schema attributes​

NameRequiredValue
commentfalsestring
namefalsestring

schema blocks​

schema.annotation​

schema.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue

schema constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., schema "name" )true

sequence​

The sequence block describes a sequence in a database schema.

sequence "name" {
schema = schema.public
type = int
increment = 3
min_value = 9
}

sequence attributes​

NameRequiredValue
cachefalseint
commentfalsestring
cyclefalsebool
incrementfalseint
max_valuefalseint
min_valuefalseint
ownerfalse

Object reference to table.column

schematrue

Object reference to schema

startfalseint
typefalse

Schema type

sequence blocks​

sequence.annotation​

sequence.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue

sequence constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., sequence "name" )true
Allow Qualifier (e.g., sequence "schema" "name" )true

server​

The server block describes a foreign server in the database.

server "foreign_server_name" {
fdw = extension.postgres_fdw
options = {
host = "127.0.0.1"
port = "5432"
dbname = "postgres"
}
}

server "foreign_server_name" {
fdw = "foreign_data_wrapper_name"
options = {
host = "127.0.0.1"
port = "5432"
dbname = "postgres"
}
}

server attributes​

Name and descriptionRequiredValue
commentfalsestring

depends_on

The depends_on attribute specifies the extensions that this server depends on.

false

List of object reference to extension

fdwtrue

Foreign data wrapper can be one of:

  1. Object reference to extension
  2. string
optionsfalsemap
typefalsestring
versionfalsestring

server constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., server "name" )true

table​

The table block describes a table in a database schema.

table "users" {
schema = schema.public
column "id" {
type = int
}
...
}

table attributes​

NameRequiredValue
access_methodfalse

Table access method can be one of:

  1. string
  2. enum (heap)
commentfalsestring
depends_onfalse

List of object references

renamed_fromfalsestring
replica_identityfalse

Replica identity for logical replication can be one of:

  1. enum (DEFAULT, NOTHING, FULL)
  2. Object reference to index
schematrue

Object reference to schema

unloggedfalsebool

table blocks​

table.annotation​

table.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue

table.check​

table.check attributes​
NameRequiredValue
commentfalsestring
exprtruestring
table.check constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

table.column​

table.column attributes​
NameRequiredValue
asfalsestring
collatefalse

Column collation can be one of:

  1. string
  2. Object reference to collation
commentfalsestring
defaultfalse

Column default value can be one of:

  1. bool
  2. string
  3. number
  4. Raw expression defined with sql("expr")
nullfalsebool
renamed_fromfalsestring
typetrue

Column type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
  3. Object reference to enum
  4. Object reference to range
  5. Object reference to domain
  6. Object reference to composite
  7. Object reference to table
  8. Object reference to view
table.column blocks​

table.column.annotation​

table.column.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue

table.column.as​

table.column.as attributes​
NameRequiredValue
exprtruestring
typefalse

enum (STORED, VIRTUAL)

table.column.identity​

table.column.identity attributes​
NameRequiredValue
generatedfalse

enum (ALWAYS, BY_DEFAULT)

incrementfalseint
startfalseint
table.column constraints​
ConstraintValue
Requiredfalse
Require Name (e.g., table.column "name" )true
Mutually exclusive sets[as (attribute), as (block)]

table.exclude​

table.exclude attributes​
NameRequiredValue
commentfalsestring
deferrablefalse

enum (INITIALLY_IMMEDIATE, INITIALLY_DEFERRED)

includefalse

Index included columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
nulls_distinctfalsebool
page_per_rangefalseint
typefalse

Index key type can be one of:

  1. string
  2. enum (BTREE, BRIN, HASH, GIN, GIST, GiST, SPGIST, SPGiST)
wherefalsestring
table.exclude blocks​

table.exclude.on​

table.exclude.on attributes​
NameRequiredValue
columnfalse

Index columns can be one of:

  1. Object reference to column
  2. Object reference to table.column
descfalsebool
exprfalsestring
opfalse

Exclude element operator can be one of:

  1. string
  2. Raw expression defined with sql("expr")
table.exclude.on constraints​
ConstraintValue
Requiredtrue
Require Namefalse
Repeatabletrue
Mutually exclusive sets[column, expr]
table.exclude constraints​
ConstraintValue
Requiredfalse
Require Name (e.g., table.exclude "name" )true

table.foreign_key​

table.foreign_key attributes​
NameRequiredValue
columnstrue

Foreign key columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
commentfalsestring
deferrablefalse

enum (INITIALLY_IMMEDIATE, INITIALLY_DEFERRED)

on_deletefalse

enum (NO_ACTION, RESTRICT, CASCADE, SET_NULL, SET_DEFAULT)

on_updatefalse

enum (NO_ACTION, RESTRICT, CASCADE, SET_NULL, SET_DEFAULT)

periodfalsebool
ref_columnstrue

Foreign key reference columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
table.foreign_key constraints​
ConstraintValue
Requiredfalse
Require Name (e.g., table.foreign_key "name" )true

table.index​

table.index attributes​
NameRequiredValue
columnsfalse

Index columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
commentfalsestring
includefalse

Index included columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
nulls_distinctfalsebool
page_per_rangefalseint
renamed_fromfalsestring
typefalse

Index key type can be one of:

  1. string
  2. enum (BTREE, BRIN, HASH, GIN, GIST, GiST, SPGIST, SPGiST)
uniquefalsebool
wherefalsestring
table.index blocks​

table.index.on​

table.index.on attributes​
NameRequiredValue
columnfalse

Index columns can be one of:

  1. Object reference to column
  2. Object reference to table.column
descfalsebool
exprfalsestring
nulls_firstfalsebool
nulls_lastfalsebool
opsfalse

Index operator class can be one of:

  1. string
  2. Raw expression defined with sql("expr")
  3. enum (bit_minmax_ops, box_inclusion_ops, bpchar_bloom_ops, bpchar_minmax_ops, bytea_bloom_ops, bytea_minmax_ops, char_bloom_ops, char_minmax_ops, date_bloom_ops, date_minmax_multi_ops, date_minmax_ops, float4_bloom_ops, float4_minmax_multi_ops, float4_minmax_ops, float8_bloom_ops, float8_minmax_multi_ops, float8_minmax_ops, inet_bloom_ops, inet_inclusion_ops, inet_minmax_multi_ops, inet_minmax_ops, int2_bloom_ops, int2_minmax_multi_ops, int2_minmax_ops, int4_bloom_ops, int4_minmax_multi_ops, int4_minmax_ops, int8_bloom_ops, int8_minmax_multi_ops, int8_minmax_ops, interval_bloom_ops, interval_minmax_multi_ops, interval_minmax_ops, macaddr8_bloom_ops, macaddr8_minmax_multi_ops, macaddr8_minmax_ops, macaddr_bloom_ops, macaddr_minmax_multi_ops, macaddr_minmax_ops, name_bloom_ops, name_minmax_ops, numeric_bloom_ops, numeric_minmax_multi_ops, numeric_minmax_ops, oid_bloom_ops, oid_minmax_multi_ops, oid_minmax_ops, pg_lsn_bloom_ops, pg_lsn_minmax_multi_ops, pg_lsn_minmax_ops, range_inclusion_ops, text_bloom_ops, text_minmax_ops, tid_bloom_ops, tid_minmax_multi_ops, tid_minmax_ops, time_bloom_ops, time_minmax_multi_ops, time_minmax_ops, timestamp_bloom_ops, timestamp_minmax_multi_ops, timestamp_minmax_ops, timestamptz_bloom_ops, timestamptz_minmax_multi_ops, timestamptz_minmax_ops, timetz_bloom_ops, timetz_minmax_multi_ops, timetz_minmax_ops, uuid_bloom_ops, uuid_minmax_multi_ops, uuid_minmax_ops, varbit_minmax_ops, array_ops, bit_ops, bool_ops, bpchar_ops, bpchar_pattern_ops, bytea_ops, char_ops, cidr_ops, date_ops, enum_ops, float4_ops, float8_ops, inet_ops, int2_ops, int4_ops, int8_ops, interval_ops, jsonb_ops, macaddr8_ops, macaddr_ops, money_ops, multirange_ops, name_ops, numeric_ops, oid_ops, oidvector_ops, pg_lsn_ops, range_ops, record_image_ops, record_ops, text_ops, text_pattern_ops, tid_ops, time_ops, timestamp_ops, timestamptz_ops, timetz_ops, tsquery_ops, tsvector_ops, uuid_ops, varbit_ops, varchar_ops, varchar_pattern_ops, xid8_ops, array_ops, jsonb_ops, jsonb_path_ops, tsvector_ops, box_ops, circle_ops, inet_ops, multirange_ops, point_ops, poly_ops, range_ops, tsquery_ops, tsvector_ops, aclitem_ops, array_ops, bool_ops, bpchar_ops, bpchar_pattern_ops, bytea_ops, char_ops, cid_ops, cidr_ops, date_ops, enum_ops, float4_ops, float8_ops, inet_ops, int2_ops, int4_ops, int8_ops, interval_ops, jsonb_ops, macaddr8_ops, macaddr_ops, multirange_ops, name_ops, numeric_ops, oid_ops, oidvector_ops, pg_lsn_ops, range_ops, record_ops, text_ops, text_pattern_ops, tid_ops, time_ops, timestamp_ops, timestamptz_ops, timetz_ops, uuid_ops, varchar_ops, varchar_pattern_ops, xid8_ops, xid_ops, box_ops, inet_ops, kd_point_ops, poly_ops, quad_point_ops, range_ops, text_ops, gin_trgm_ops, gist_trgm_ops, btree_geography_ops, btree_geometry_ops, gist_geography_ops, gist_geometry_ops_2d, gist_geometry_ops_nd, gist_geometry_ops_3d, hash_geometry_ops, brin_geography_inclusion_ops, brin_geometry_inclusion_ops_2d, brin_geometry_inclusion_ops_3d, brin_geometry_inclusion_ops_4d, spgist_geography_ops_nd, spgist_geometry_ops_2d, spgist_geometry_ops_3d, spgist_geometry_ops_nd)
table.index.on constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Mutually exclusive sets[column, expr], [nulls_last, nulls_first]

table.index.storage_params​

table.index.storage_params attributes​
NameRequiredValue
autosummarizefalsebool
bufferingfalse

enum (ON, OFF, AUTO)

deduplicate_itemsfalsebool
fastupdatefalsebool
fillfactorfalseint
gin_pending_list_limitfalseint
pages_per_rangefalseint
table.index.storage_params constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown attributestrue
table.index constraints​
ConstraintValue
Requiredfalse
Require Name (e.g., table.index "name" )true
Mutually exclusive sets[columns, on], [page_per_range, storage_params]
One of required sets[columns, on]

table.partition​

table.partition attributes​
NameRequiredValue
columnsfalse

Partition columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
typetrue

enum (RANGE, LIST, HASH)

table.partition blocks​

table.partition.by​

table.partition.by attributes​
NameRequiredValue
columnfalse

Partition columns can be one of:

  1. Object reference to column
  2. Object reference to table.column
exprfalsestring
table.partition.by constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue
Mutually exclusive sets[column, expr]

table.primary_key​

table.primary_key attributes​
NameRequiredValue
columnstrue

Primary key columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
commentfalsestring
deferrablefalse

enum (INITIALLY_IMMEDIATE, INITIALLY_DEFERRED)

includefalse

Primary key included columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
page_per_rangefalseint
typefalse

Index key type can be one of:

  1. string
  2. enum (BTREE, BRIN, HASH, GIN, GIST, GiST, SPGIST, SPGiST)
without_overlapsfalsebool
table.primary_key blocks​

table.primary_key.storage_params​

table.primary_key.storage_params attributes​
NameRequiredValue
autosummarizefalsebool
bufferingfalse

enum (ON, OFF, AUTO)

deduplicate_itemsfalsebool
fastupdatefalsebool
fillfactorfalseint
gin_pending_list_limitfalseint
pages_per_rangefalseint
table.primary_key.storage_params constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown attributestrue
table.primary_key constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[page_per_range, storage_params]

table.row_security​

table.row_security attributes​
NameRequiredValue
enabledfalsebool
enforcedfalsebool

table.storage_params​

table.storage_params attributes​
NameRequiredValue
autovacuum_analyze_scale_factorfalsenumber
autovacuum_analyze_thresholdfalseint
autovacuum_enabledfalsebool
autovacuum_freeze_max_agefalseint
autovacuum_freeze_min_agefalseint
autovacuum_freeze_table_agefalseint
autovacuum_multixact_freeze_max_agefalseint
autovacuum_multixact_freeze_min_agefalseint
autovacuum_multixact_freeze_table_agefalseint
autovacuum_vacuum_cost_delayfalsenumber
autovacuum_vacuum_cost_limitfalseint
autovacuum_vacuum_insert_scale_factorfalsenumber
autovacuum_vacuum_insert_thresholdfalseint
autovacuum_vacuum_max_thresholdfalseint
autovacuum_vacuum_scale_factorfalsenumber
autovacuum_vacuum_thresholdfalseint
fillfactorfalseint
log_autovacuum_min_durationfalseint
parallel_workersfalseint
toast_tuple_targetfalseint
user_catalog_tablefalsebool
vacuum_index_cleanupfalse

enum (ON, OFF, AUTO)

vacuum_max_eager_freeze_failure_ratefalsenumber
vacuum_truncatefalsebool
table.storage_params constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown attributestrue

table.unique​

table.unique attributes​
NameRequiredValue
columnstrue

Index columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
commentfalsestring
deferrablefalse

enum (INITIALLY_IMMEDIATE, INITIALLY_DEFERRED)

includefalse

Index included columns can be one of:

  1. List of object reference to column
  2. List of object reference to table.column
nulls_distinctfalsebool
typefalse

Index key type can be one of:

  1. string
  2. enum (BTREE, BRIN, HASH, GIN, GIST, GiST, SPGIST, SPGiST)
without_overlapsfalsebool
table.unique blocks​

table.unique.storage_params​

table.unique.storage_params attributes​
NameRequiredValue
autosummarizefalsebool
bufferingfalse

enum (ON, OFF, AUTO)

deduplicate_itemsfalsebool
fastupdatefalsebool
fillfactorfalseint
gin_pending_list_limitfalseint
pages_per_rangefalseint
table.unique.storage_params constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown attributestrue
table.unique constraints​
ConstraintValue
Requiredfalse
Require Name (e.g., table.unique "name" )true
Mutually exclusive sets[page_per_range, storage_params]

table constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., table "name" )true
Allow Qualifier (e.g., table "schema" "name" )true

trigger​

The trigger block describes a trigger on a table in a database schema.

trigger "trigger_orders_audit" {
on = table.orders
...
}

trigger attributes​

NameRequiredValue
asfalsestring
commentfalsestring
constraintfalsebool
deferrablefalse

enum (INITIALLY_IMMEDIATE, INITIALLY_DEFERRED)

forfalse

enum (ROW, STATEMENT)

foreachfalse

enum (ROW, STATEMENT)

fromfalse

Object reference to table

ontrue

Trigger on can be one of:

  1. Object reference to table
  2. Object reference to view
  3. Object reference to partition
whenfalsestring

trigger blocks​

trigger.after​

trigger.after attributes​
NameRequiredValue
deletefalsebool
insertfalsebool
truncatefalsebool
updatefalsebool
update_offalse

Trigger update_of columns can be one of:

  1. List of object reference to view.column
  2. List of object reference to table.column
trigger.after constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[update, update_of]
One of required sets[insert, delete, truncate, update, update_of]

trigger.annotation​

trigger.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue

trigger.before​

trigger.before attributes​
NameRequiredValue
deletefalsebool
insertfalsebool
truncatefalsebool
updatefalsebool
update_offalse

Trigger update_of columns can be one of:

  1. List of object reference to view.column
  2. List of object reference to table.column
trigger.before constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[update, update_of]
One of required sets[insert, delete, truncate, update, update_of]

trigger.execute​

trigger.execute attributes​
NameRequiredValue
argsfalse

List of strings

functionfalse

Trigger function (reference or expression) can be one of:

  1. Object reference to function
  2. Raw expression defined with sql("expr")
procedurefalse

Object reference to procedure

trigger.execute constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[function, procedure]
One of required sets[function, procedure]

trigger.instead_of​

trigger.instead_of attributes​
NameRequiredValue
deletefalsebool
insertfalsebool
truncatefalsebool
updatefalsebool
update_offalse

Trigger update_of columns can be one of:

  1. List of object reference to view.column
  2. List of object reference to table.column
trigger.instead_of constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Mutually exclusive sets[update, update_of]
One of required sets[insert, delete, truncate, update, update_of]

trigger.referencing​

trigger.referencing attributes​
NameRequiredValue
new_tablefalsestring
old_tablefalsestring
trigger.referencing constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

trigger constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., trigger "name" )true
Repeatabletrue
Mutually exclusive sets[foreach, for], [before, after, instead_of], [as, execute]
One of required sets[before, after, instead_of], [as, execute]

user​

The user block describes a database user.

user "app_user" {
password = "<sensitive>"
valid_until = "2025-12-31 23:59:59+00"
member_of = [role.readers]
comment = "Application user"
}

user attributes​

NameRequiredValue
bypass_rlsfalsebool
commentfalsestring
conn_limitfalseint
create_dbfalsebool
create_rolefalsebool
externalfalsebool
inheritfalsebool
member_offalse

List of object reference to role

namefalsestring
passwordfalsestring
replicationfalsebool
superuserfalsebool
valid_untilfalsestring

user blocks​

user.membership​

The membership block describes a membership in a role, along with its options.

user "vault" {
membership {
role = role.reader
admin = true
}
}
user.membership attributes​
NameRequiredValue
adminfalsebool
inheritfalsebool
roletrue

Object reference to role

setfalsebool
user.membership constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

user constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., user "name" )true

user_mapping​

The user_mapping block describes a user mapping for a foreign server.

user_mapping {
server = server.my_server
user = "postgres"
options = {
user = "remote_user"
password = "secret"
}
}
user_mapping {
server = server.my_server
user = user.dba
}

user_mapping attributes​

NameRequiredValue
optionsfalsemap
servertrue

Foreign server can be one of:

  1. Object reference to server
  2. string
usertrue

Local user or role can be one of:

  1. enum (PUBLIC, CURRENT_USER, CURRENT_ROLE, SESSION_USER, USER)
  2. string
  3. Object reference to role
  4. Object reference to user

user_mapping constraints​

ConstraintValue
Requiredfalse
Require Namefalse
Repeatabletrue

view​

The view block describes a view in a database schema.

view "clean_users" {
schema = schema.public
column "id" {
type = int
}
...
}

view attributes​

NameRequiredValue
astruestring
check_optionfalse

enum (LOCAL, CASCADED)

commentfalsestring
depends_onfalse

List of object references

schematrue

Object reference to schema

view blocks​

view.annotation​

view.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue

view.column​

view.column attributes​
NameRequiredValue
commentfalsestring
nullfalsebool
typetrue

Column type can be one of:

  1. Schema type
  2. Raw expression defined with sql("expr")
  3. Object reference to enum
  4. Object reference to range
  5. Object reference to domain
  6. Object reference to composite
  7. Object reference to table
  8. Object reference to view
view.column blocks​

view.column.annotation​

view.column.annotation constraints​
ConstraintValue
Requiredfalse
Require Namefalse
Allow unknown blockstrue
Allow unknown attributestrue
view.column constraints​
ConstraintValue
Requiredfalse
Require Name (e.g., view.column "name" )true

view.security​

view.security attributes​
NameRequiredValue
barrierfalsebool
invokerfalsebool
view.security constraints​
ConstraintValue
Requiredfalse
Require Namefalse
One of required sets[invoker, barrier]

view constraints​

ConstraintValue
Requiredfalse
Require Name (e.g., view "name" )true
Allow Qualifier (e.g., view "schema" "name" )true