> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/database-devops/use-db-devops/deployment-pipeline-configuration/step-types/test-and-preview.md).

# DB Test and Preview step

The **DB Test and Preview** step validates a database changeset generated by the **Author DB Change** feature before the changeset is committed to your Git repository. It runs the candidate migration against the selected DB Instance in a dry-run mode and surfaces the output, errors, and a preview of the SQL that would be applied, allowing you to review and approve the change before it is merged.

{% hint style="info" %}
The DB Test and Preview step is exclusively used as part of the **Author DB Change** workflow. It is not a general-purpose apply or validate step. Go to [Configure Author DB Change](/database-devops/use-db-devops/create-database-updates/configure-llm-for-database-devops.md) to set up the full LLM authoring pipeline that uses this step.
{% endhint %}

### Before you begin <a href="#before-you-begin" id="before-you-begin"></a>

* **Harness AI enabled:** Author DB Change requires Harness AI to be enabled at the account level. Go to [Configure Author DB Change](/database-devops/use-db-devops/create-database-updates/configure-llm-for-database-devops.md) to enable Harness AI and configure the LLM authoring pipeline identifier.
* **LLM authoring pipeline:** This step must be part of the pipeline referenced in **Account Settings > Default Settings > Database DevOps > LLM Authoring Test and Commit Pipeline**. The pipeline identifier must match exactly.

### Add the DB Test and Preview step <a href="#add-the-db-test-and-preview-step" id="add-the-db-test-and-preview-step"></a>

The DB Test and Preview step is added to a **Custom Stage** pipeline that serves as the LLM authoring pipeline.

1. In Harness, go to **Database DevOps** and select your project.
2. Create or open the pipeline designated as the LLM authoring pipeline (the identifier must match the one configured in account default settings).
3. Add a **Custom Stage** with a step group.
4. Inside the step group, select **Add Step** and choose **DB Test and Preview**.
5. Configure the step parameters described below.
6. Select **Apply Changes** and save the pipeline.

### Step parameters <a href="#step-parameters" id="step-parameters"></a>

![DBDevOps Test and Preview Step](/files/czSf7aHqQVplrYa6xp3S)

1. **Name** - Display name for the step. Default is `DBTestAndPreview_1`.
2. **Timeout** - Maximum duration before the step times out. Default is `20m`, which accommodates the time needed to spin up a container, run the migration tool, and return output.
3. **Container Registry** - Select the container registry connector that Harness uses to pull the migration container. (Use the Docker Registry)
4. Leave the following fields as runtime inputs (`<+input>`). The Author DB Change workflow populates them automatically when it invokes the pipeline.

* **Select DB Schema** - The DB Schema against which the generated changeset will be previewed. Set as `<+input>`.
* **Select DB Instance** - The DB Instance that will receive the preview run. Set as `<+input>`.
* **Changeset** - The changeset content generated by the LLM. Set as `<+input>`.

### How it fits in the Author DB Change pipeline <a href="#how-it-fits-in-the-author-db-change-pipeline" id="how-it-fits-in-the-author-db-change-pipeline"></a>

A typical LLM authoring pipeline uses two steps:

1. **DB Test and Preview**: validates the generated changeset against the target DB Instance and writes the changeset files to the `dbops/DBTestAndPreview_1` directory in the runner workspace.
2. **Run step**: checks out the generated files, pushes them to a new branch in your Git repository, and opens a Pull Request for human review and CI validation.

Go to [Configure Author DB Change](/database-devops/use-db-devops/create-database-updates/configure-llm-for-database-devops.md) for the full pipeline setup, including the Run step script for GitHub, Bitbucket, and Harness Code.

### Next steps <a href="#next-steps" id="next-steps"></a>

* Go to [Configure Author DB Change](/database-devops/use-db-devops/create-database-updates/configure-llm-for-database-devops.md) to set up the full LLM authoring pipeline.
* Go to [Apply DB Schema step](/database-devops/use-db-devops/deployment-pipeline-configuration/step-types/apply-dbschema-step.md) to apply approved changesets to your database instances via a deployment pipeline.
