> For the complete documentation index, see [llms.txt](https://docs.paradime.io/app-help/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.paradime.io/app-help/integrations/elementary-data/schema-tests/schema-changes-from-baseline.md).

# Schema changes from baseline

The `elementary.schema_changes_from_baseline` test checks for schema changes against baseline columns defined in a source's or model's configuration. For this test to work, the configuration should contain columns and data types.

### Sources configuration

{% tabs %}
{% tab title="Sources" %}

```yaml
version: 2

sources:
  - name: < source name >
    database: < database name >
    schema: < schema name >
    tables:
      - name: < table name >
        columns:
          - name: < column 1 >
            data_type: < data type 1 >
          - name: < column 2 >
            data_type: < data type 2 >
        tests:
          - elementary.schema_changes_from_baseline
```

{% endtab %}

{% tab title="Sources example" %}

```yaml
version: 2

sources:
  - name: < source name >
    database: < database name >
    schema: < schema name >
    tables:
      - name: < table name >
        columns:
          - name: < column 1 >
            data_type: < data type 1 >
          - name: < column 2 >
            data_type: < data type 2 >
        tests:
          - elementary.schema_changes_from_baseline
```

{% endtab %}
{% endtabs %}

### Models configuration

{% tabs %}
{% tab title="Models" %}

```yaml
version: 2

models:
  - name: < model name >
    columns:
      - name: < column 1 >
        data_type: < data type 1 >
      - name: < column 2 >
        data_type: < data type 1 >
    tests:
      - elementary.schema_changes_from_baseline
```

{% endtab %}

{% tab title="Models example" %}

```yaml
version: 2

models:
  - name: login_events
    columns:
      - name: event_name
        data_type: text
      - name: event_id
        data_type: integer
    tests:
      - elementary.schema_changes_from_baseline:
          tags: ["elementary"]
```

{% endtab %}
{% endtabs %}

### Supported Parameters

* `fail_on_added`: If set, the test will fail if there are columns in the table that do not exist in the baseline (default: False).
* `enforce_types`: If set, the test will raise an error if there are columns defined without a data type (default: False).

### Auto-generate Baseline Schema

To make it easier to configure schema tests, Elementary provides dbt operations to auto-generate tests configuration based on the existing schemas.

#### Usage

```bash
# Generate a schema changes from baseline test for all sources
dbt run-operation elementary.generate_schema_baseline_test

# Generate a test for a specific model/source named "orders"
dbt run-operation elementary.generate_schema_baseline_test --args '{"name": "orders"}'

# Generate tests for all sources and all models
dbt run-operation elementary.generate_schema_baseline_test --args '{"include_models": true}'

# Generate tests with "fail_on_added" and "enforce_types" set to true
dbt run-operation elementary.generate_schema_baseline_test --args '{"fail_on_added": true, "enforce_types": true}'
```

This command will output the generated configuration for the schema changes from baseline test, which can be copied and pasted into the relevant `yml` file.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.paradime.io/app-help/integrations/elementary-data/schema-tests/schema-changes-from-baseline.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
