From 296a12c871f1d0fa958b84521827ad4cdeecd786 Mon Sep 17 00:00:00 2001 From: Ariel Mashraki <7413593+a8m@users.noreply.github.com> Date: Tue, 30 Apr 2024 15:04:57 +0300 Subject: [PATCH] doc: add exclusion constraint to hcl (#2732) --- doc/md/atlas-schema/hcl.mdx | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/doc/md/atlas-schema/hcl.mdx b/doc/md/atlas-schema/hcl.mdx index 26d271aafff..b3dc95358a0 100644 --- a/doc/md/atlas-schema/hcl.mdx +++ b/doc/md/atlas-schema/hcl.mdx @@ -777,6 +777,39 @@ concurrently first and then converted to a unique constraint. To achieve this, f 4. Replace the `index` block with a `unique` block to create a new unique constraint using the existing index. ::: +### Exclude Constraints + +The `exclude` block allows defining a [exclusion constraint](https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-EXCLUSION) +supported by PostgreSQL: + +```hcl +exclude "excl_speaker_during" { + type = GIST + on { + column = column.speaker + op = "=" + } + on { + column = column.during + op = "&&" + } +} + +# Include non-key columns. +exclude "excl_speaker_during" { + type = GIST + on { + column = column.speaker + op = "=" + } + on { + column = column.during + op = "&&" + } + include = [column.another] +} +``` + ## Trigger :::info LOGIN REQUIRED