# dbt sync

> Generate dbt tests and model metadata from one or more ODCS contracts.

# `datacontract dbt sync`

{/* AUTOGENERATED from `datacontract --help`: do not edit by hand; regenerate with update_command_docs.py */}

Generate dbt tests and model metadata from one or more ODCS contracts. Modifies the existing dbt model YAML in place (preserving comments and formatting), and creates new model YAML files or singular SQL tests if needed. Use `datacontract dbt test` or pass --run-tests to run the generated tests.

```bash
datacontract dbt sync [OPTIONS] [CONTRACT]...
```

| Argument | Default | Description |
|---|---|---|
| `[CONTRACT]...` | — | Path(s) or glob(s) of ODCS contracts to sync. If omitted, syncs every `*.odcs.yaml` under --project-dir (default: current directory) and its subdirectories. |

| Option | Default | Description |
|---|---|---|
| `--project-dir` | — | Path to the dbt project root (must contain `dbt_project.yml`). Defaults to the current directory. |
| `--schema-name` | `all` | Which ODCS schema object to sync, by name. |
| `--model-resolution` | `name` | How to map an ODCS schema to a dbt model name. |
| `--target` | — | Forwarded to `dbt test --target`. |
| `--profiles-dir` | — | Forwarded to `dbt test --profiles-dir`. |
| `--prune` / `--no-prune` | `--no-prune` | Remove model columns and tags that are not declared in the contract. |
| `--run-tests` / `--skip-tests` | `--skip-tests` | Run `dbt test` on the generated tests after syncing. Default: skip (generate only). |
| `--publish` | — | The url to publish the results after the test. |
| `--server` | — | Selected ODCS server. Determines the dialect for data types and for the server label when publishing results. Default: Auto-selected if only one server exists, else --target. |
| `--ssl-verification` / `--no-ssl-verification` | `--ssl-verification` | SSL verification when publishing test results. |
| `--debug` / `--no-debug` | — | Enable debug logging |

```bash
datacontract dbt sync orders.odcs.yaml --project-dir ./warehouse
```
