Skip to content

Commit

Permalink
Update constraints.md (#6053)
Browse files Browse the repository at this point in the history
  • Loading branch information
mirnawong1 authored Sep 13, 2024
2 parents 413ec23 + 599f112 commit f2beaae
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions website/docs/reference/resource-properties/constraints.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ The structure of a constraint is:
- `name` (optional): Human-friendly name for this constraint. Supported by some data platforms.
- `columns` (model-level only): List of column names to apply the constraint over

<VersionBlock lastVersion="1.8">

When using `foreign_key`, you need to specify the referenced table's schema manually. Use `{{ target.schema }}` in the `expression` field to automatically pass the schema used by the target environment. Note that later versions of dbt will have more efficient ways of handling this.

For example: `expression: "{{ target.schema }}.customers(customer_id)"`

</VersionBlock>

<File name='models/schema.yml'>

```yml
Expand Down Expand Up @@ -62,6 +70,8 @@ models:
</File>
## Platform-specific support
In transactional databases, it is possible to define "constraints" on the allowed values of certain columns, stricter than just the data type of those values. For example, Postgres supports and enforces all the constraints in the ANSI SQL standard (`not null`, `unique`, `primary key`, `foreign key`), plus a flexible row-level `check` constraint that evaluates to a boolean expression.
Expand Down

0 comments on commit f2beaae

Please sign in to comment.