> 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/rollback-and-failure-strategies/using-rollback-tags.md).

# Using Rollback Tags with Apply Schema Step

When deploying database changeSets in Harness, rollback safety is built-in. The **Apply Schema** step ensures that every deployment is checkpointed with a rollback tag (`preStartTag`). This tag can be reused or created automatically, giving teams a reliable way to revert changes if needed.

### How it works <a href="#how-it-works" id="how-it-works"></a>

When the Apply Schema step runs in a pipeline:

1. Harness checks if the last deployed changeSet already has a tag.
2. If a tag exists, Harness will reuse it.
3. If no tag is found, Harness automatically creates a new tag before running the update command. This ensures that every deployment has a safe checkpoint for rollback.

### Access rollback tags <a href="#access-rollback-tags" id="access-rollback-tags"></a>

You can access the rollback tag value with Harness expressions:

* **Within the same stage**

  ```yaml
  <+execution.steps.stepGroupIdentifier.steps.stepIdentifier.output.preStartTag>
  ```
* **Across pipeline**

  ```yaml
  <+pipeline.stages.stageIdentifier.spec.execution.steps.stepGroupIdentifier.steps.stepIdentifier.output.preStartTag>
  ```

Here’s what each part means:

* `stageIdentifier`: The stage where your Apply Schema step runs.
* `stepGroupIdentifier`: The step group containing your Apply Schema step.
* `stepIdentifier`: The Apply Schema step itself.
* `preStartTag`: The tag value Harness captures before running the update.

### Best practices <a href="#best-practices" id="best-practices"></a>

* Use consistent tag naming conventions (e.g., release-2025-09-22).
* Store rollback [tags](/database-devops/3.0/use-db-devops/reference/glossary/tag.md) in external audit systems for traceability.
* Always verify tags before running deployments in production.
* Integrate rollback tags into approval steps for safer rollouts.
* When deploying a git-based schema, tag using the git sha
* when deploying an artifactory-based schema, tag using the artifact version

### FAQ <a href="#faq" id="faq"></a>

#### 1. Is this different from Liquibase tags? <a href="#id-1-is-this-different-from-liquibase-tags" id="id-1-is-this-different-from-liquibase-tags"></a>

Yes. Liquibase requires manual tagging. Harness automates this process, ensuring a rollback tag is always captured. No missed steps, no manual scripts.

#### 2. Can I export tags for external systems? <a href="#id-2-can-i-export-tags-for-external-systems" id="id-2-can-i-export-tags-for-external-systems"></a>

Yes, rollback tags can be logged or passed into monitoring and audit tools. It can also be queried via this API Endpoint - `https://apidocs.harness.io/migration-state/v1migrationstateprojdbinstance`

#### 3. What if no previous tag exists? <a href="#id-3-what-if-no-previous-tag-exists" id="id-3-what-if-no-previous-tag-exists"></a>

Harness creates one automatically before the update, ensuring rollback safety every time.

#### 4. Why use Harness instead of Liquibase directly? <a href="#id-4-why-use-harness-instead-of-liquibase-directly" id="id-4-why-use-harness-instead-of-liquibase-directly"></a>

Harness Database DevOps builds on top of Liquibase capabilities but adds pipeline automation, visibility, governance, auditability, and intelligent defaults like automatic tagging. This means:

```
- You don’t need to write custom scripts for rollback safety.
- Rollbacks are standardized across all environments.
- Teams save time by using built-in pipeline steps instead of managing manual Liquibase commands.
```

#### 5. How does this improve CI/CD for databases? <a href="#id-5-how-does-this-improve-cicd-for-databases" id="id-5-how-does-this-improve-cicd-for-databases"></a>

Tags ensure every schema deployment is checkpointed. Combined with Harness pipelines, this makes database delivery as safe and repeatable as application delivery.

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

* Go to [Rollback for database schemas](/database-devops/use-db-devops/deployment-pipeline-configuration/rollback-and-failure-strategies/rollback-for-database-schemas.md) to configure automated rollback strategies.
* Go to [Apply a DB schema step](/database-devops/use-db-devops/deployment-pipeline-configuration/step-types/apply-dbschema-step.md) to learn how the Apply Schema step generates rollback tags.
