Skip to content

Index

Defines an index on a table

Properties

Property Type Required Description
name string — The index name.
sql string — User-provided raw SQL snippet.
unique boolean — Specifies that the index is a unique index. Default: false.
recurse boolean — Used to specify that the index should be created on partitions of the table. False for an index of a partitioned table that is made with ON ONLY: each partition then has its own index, with a parent.
parent string — The index of the partitioned table that this index of a partition belongs to (ALTER INDEX parent ATTACH PARTITION), schema-qualified, with each part quoted as an SQL identifier when it needs quotes. That index must have recurse set to false.
method string — The name of the index method to be used: a built-in one (brin, btree, gin, gist, hash or spgist) or one made with CREATE ACCESS METHOD. Default: "btree".
columns array of object — Defines the columns that are indexed.
include array of string — Use to provide a list of non-key columns to provide in the index.
storage_parameters object — Storage parameter settings for the index.
tablespace string — Specifies the tablespace to use when creating the index.
nulls_not_distinct boolean — Renders NULLS NOT DISTINCT on a unique index (PostgreSQL 15+), where one null equals another. Absent means nulls are distinct, the default.
where string — Use to provide an expression for creating a partial index.
comment string — An optional comment about the table.
dependencies dependencies — Database objects this object is dependent upon.

columns[]

Property Type Required Description
name string — Specify either the column name, mutally exclusive from expression.
expression string — Specify an expression for the column, mutally exclusive from name.
collation string — Assigns a collation to the column (which must be of a collatable data type). If not specified, the column data type's default collation is used.
opclass string — The name of an operator class.
direction ASC | DESC — Specifies the sort direction in the index for the column. Default: "ASC".
null_placement FIRST | LAST — Specifies the placement of null values in the index.

Mutually exclusive forms

Exactly one of these must hold:

  • name, without expression
  • expression, without name

Mutually exclusive forms

Exactly one of these must hold:

  • sql, without name or method or columns or storage_parameters or unique or recurse or include or where
  • name and columns, without sql

No other properties are accepted.


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