> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trydatawise.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Schema Guardian

Schema Guardian is Datawise's pre-merge detection layer. It analyzes GitHub pull requests, identifies schema changes that would break downstream assets, and posts a bot comment directly in the PR before anyone clicks merge.

## How It Works

When a pull request is opened or updated in a connected GitHub repo:

1. Datawise fetches the PR diff from GitHub.
2. SQL and dbt model files are parsed to identify schema modifications.
3. Changes are classified as breaking, potentially breaking, or safe using AI analysis.
4. Downstream impact is resolved using your connected warehouse lineage and dbt model graph.
5. A bot comment is posted in the PR with the full analysis.

The bot comment updates automatically on each new commit to the PR.

## What Schema Guardian Detects

| Change Type                                    | Classification       |
| ---------------------------------------------- | -------------------- |
| Column removal                                 | Breaking             |
| Column rename                                  | Breaking             |
| Data type narrowing (e.g., `VARCHAR` to `INT`) | Breaking             |
| Model restructure that removes output columns  | Breaking             |
| Data type widening (e.g., `INT` to `BIGINT`)   | Potentially breaking |
| New column added                               | Safe                 |
| Index or constraint change only                | Safe                 |
| Comment-only changes                           | Safe                 |

## The Bot Comment

The bot comment contains:

* **Change Summary** — plain-language description of what changed and in which file.
* **Severity** — breaking changes are highlighted.
* **Downstream Impact** — which dbt models, Tableau workbooks, and Power BI reports depend on the changed asset.
* **Mitigation Recommendations** — specific steps to resolve each breaking change before merging.

## Merge Protection

When enabled, Datawise posts a GitHub status check alongside the bot comment. If a breaking change is detected, the check returns `failure` and the merge button is blocked.

Available on: **Pro and Enterprise**.

To enable:

1. Go to **Settings > Merge Protection** in Datawise.
2. Toggle on the repos where you want enforcement.
3. In GitHub, add `datawise/schema-guardian` as a required status check in your branch protection rules.

<Note>
  Admin users can override a blocked merge from the Schema Guardian view in Datawise when a bypass is necessary.
</Note>

## Requirements

* GitHub connector connected. See [GitHub Setup](/connectors/github).
* dbt Cloud connector required for downstream dbt model impact resolution.
* Tableau and Power BI connectors required for BI-layer downstream impact.

## Frequently Asked Questions

<AccordionGroup>
  <Accordion title="Does Schema Guardian analyze historical PRs?">
    No. Analysis begins from the point of connection. Historical PRs are not retroactively analyzed.
  </Accordion>

  <Accordion title="What if the PR changes non-SQL files?">
    Schema Guardian ignores file types it doesn't recognize. Only SQL and dbt model files are analyzed.
  </Accordion>

  <Accordion title="Can I customize what counts as a breaking change?">
    Not currently. Configurable severity thresholds are on the roadmap.
  </Accordion>
</AccordionGroup>
