Help with yaml config for foreign_key

I’m trying to create a foreign_key relationship in my model .yml file, but I’m unsure how the syntax for the expression works - I have the primary_keys working… how do I add the right variables for… “<other_model_schema>” etc.


        # column-level constraints
        constraints:
          - type: not_null
          - type: unique
          - type: foreign_key
            expression: <other_model_schema>.<other_model_name> (<other_model_column>)
          - type: ...

And this is what my setup looks like so far:

  - name: org_ancestors
    config:
      contract:
        enforced: true
    columns:
      - name: org_id
        data_type: varchar(256)
        constraints:
          - type: foreign_key
            expression: dev_brian.orgs (org_id)     

Error:

yntax error line 4 at position 36 unexpected 'orgs'.
syntax error line 4 at position 41 unexpected '('.
syntax error line 5 at position 13 unexpected 'varchar'.
syntax error line 5 at position 20 unexpected '('.

I got it - and it was as literal as the docs said - i’m not sure why the 105k combinations I tried up to this point didn’t work:

  - name: org_ancestors
    config:
      contract:
        enforced: true
    columns:
      - name: org_id
        data_type: varchar(256)
        constraints:
          - type: foreign_key
            expression: fxdmz.dev_brian.orgs (org_id)

I still have the issue of a hard coded part of that db string - but I can research that tomorrow - but it looks like this issue is close to what i’m referring to:

https://github.com/dbt-labs/dbt-core/issues/8062