> 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/rollback-dbschema-step.md).

# Rollback DB Schema step

The **Rollback DB Schema** step reverts previously applied database changesets on a target DB instance as part of a Harness pipeline. It is typically added after an [Apply DB Schema step](/database-devops/use-db-devops/deployment-pipeline-configuration/step-types/apply-dbschema-step.md) as part of a failure strategy or a dedicated rollback stage.

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

Ensure the following conditions are met before adding this step to your pipeline.

* **Applied migrations:** Rollback requires changesets previously applied by an Apply DB Schema step. Nothing can be rolled back on a fresh instance with no applied changesets.
* **Rollback scripts:** Liquibase rollback requires that each changeset defines a rollback statement. Go to [Automatic and Custom Rollback](/database-devops/use-db-devops/deployment-pipeline-configuration/rollback-and-failure-strategies/automatic-and-custom-rollback.md) to understand when rollback scripts are required.
* **Tag (for rollback by tag):** The target tag must exist in `DATABASECHANGELOG`. Go to [Using Rollback Tags with Apply Schema](/database-devops/use-db-devops/deployment-pipeline-configuration/rollback-and-failure-strategies/using-rollback-tags.md) to learn how tags are created.

### Add the Rollback DB Schema step <a href="#add-the-rollback-db-schema-step" id="add-the-rollback-db-schema-step"></a>

1. In Harness, go to **Database DevOps** and select your project.
2. Open your pipeline and select the stage where you want to configure rollback.
3. Add a **Custom Stage** with a step group.
4. Inside the step group, **Add Step** and choose **Rollback DB Schema**.
5. Configure the step parameters described below.
6. Select **Apply Changes**, then save and run the pipeline.

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

![DBDevOps Rollback DBSchema Step](/files/inxFKlHFB8S0g4YC540A)

1. **Name** - Display name for the step. The step ID is derived from this name.
2. **Timeout** - Maximum duration before the step times out. Default is `10m`.
3. **Container Registry** - Select the container registry connector that Harness uses to pull the migration container.
4. **Migration Type** - Select **Liquibase** or **Flyway** depending on your schema's migration tool.
5. **Select DB Schema** - Choose the DB Schema associated with the instance you want to roll back.
6. **Select DB Instance** - Choose the DB Instance where the rollback will be executed.
7. **Specify rollback target** - Choose how to identify the rollback target: rollback to a specific tag, rollback by count, or rollback to a target version (Flyway). Go to [Rollback for Database Schemas](/database-devops/use-db-devops/deployment-pipeline-configuration/rollback-and-failure-strategies/rollback-for-database-schemas.md) for details on each method.

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

* Go to [Apply DB Schema step](/database-devops/use-db-devops/deployment-pipeline-configuration/step-types/apply-dbschema-step.md) to configure the apply step that precedes rollback.
* Go to [Rollback for Database Schemas](/database-devops/use-db-devops/deployment-pipeline-configuration/rollback-and-failure-strategies/rollback-for-database-schemas.md) to understand rollback methods, automated rollback patterns, and failure strategies.
* Go to [Automatic and Custom Rollback](/database-devops/use-db-devops/deployment-pipeline-configuration/rollback-and-failure-strategies/automatic-and-custom-rollback.md) to learn how to write rollback scripts for complex changesets.
