> 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/tag-database-changeset.md).

# Tag Database Changeset

The Tag Database Changeset option is available on the Apply Schema step under Harness Database DevOps. When enabled, it ensures that a post-deployment tag is recorded even when a deployment applies ze

{% @harness-feedback/feedback %}

### Why this matters <a href="#why-this-matters" id="why-this-matters"></a>

By default, Harness skips the post-tag apply when a deployment results in zero applied changesets (a no-op deployment). This means no tag row is written to `DATABASECHANGELOG` for that run.

In multi-service release workflows this creates a gap: if you need to roll back all services to a consistent state, a service that had a no-op deployment has no tag anchor for that release. Rolling back in sync across services becomes unreliable.

**Tag Database Changeset** closes this gap by writing a synthetic changeset row into `DATABASECHANGELOG` with the post-tag value, even when there are no real schema changes to apply.

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

When **Tag Database Changeset** is enabled and a deployment results in zero applied changesets, Harness checks whether the post-tag already exists as the latest row in `DATABASECHANGELOG`:

* **Tag already exists on the latest row:** Harness skips insertion and logs a notice.
* **No tag on the latest row:** Harness updates that row with the tag value directly. No synthetic row is created.
* **A different tag on the latest row:** Harness inserts a synthetic tag-marker row with a stable identity so rollback can detect and clean it up:
  * **Changelog path:** `liquibase-internal`
  * **Author:** `harness`
  * **ID:** `harness_<sanitizedTag>` (non-alphanumeric characters in the tag are replaced with `_`; for example `1.1.0-4.33` becomes `harness_1_1_0_4_33`)
  * The row is recorded with status `EXECUTED` and synced to Harness migration state and command execution history.

When a deployment applies **one or more changesets**, the post-tag runs normally and no synthetic row is created, regardless of whether the checkbox is enabled.

### Enable Tag Database Changeset <a href="#enable-tag-database-changeset" id="enable-tag-database-changeset"></a>

To enable this option in your Database DevOps pipeline, complete the following steps:

1. In your pipeline, add or edit an **Apply Schema** step.
2. In the Apply Schema step, under **Specific Tag to Create**, add the tag value you want to use for the post-deployment tag.
3. Under **Global Settings**, check the option:
   * **Tag Database Changeset** (disabled by default).
4. Save your changes and run the pipeline.

<figure><img src="https://4089095456-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWwqb27iUU3gZvwGNroZp%2Fuploads%2FhqntWjODwnlJp3c38Mbm%2Fimage.png?alt=media&amp;token=b1b8f7de-09ac-4616-9616-71e8a3e93b5a" alt=""><figcaption></figcaption></figure>

### Rollback behavior <a href="#rollback-behavior" id="rollback-behavior"></a>

When rolling back to a tag, Harness performs additional cleanup for synthetic tag-marker rows:

* After the rollback completes, Harness removes synthetic tag-marker rows that occur after the rollback target tag.
* The synthetic marker row for the rollback target tag itself is preserved as the rollback anchor.
* Each removed orphan row is logged in the step output as `Rolling Back Changeset: <changeset-id>`.

### When to use Tag Database Changeset <a href="#when-to-use-tag-database-changeset" id="when-to-use-tag-database-changeset"></a>

Use this option when:

* You deploy across multiple services and need every service to have a tag anchor for each release, including releases where a service had no schema changes.
* You rely on rollback-to-tag for synchronized multi-service rollbacks.

Do not enable this option if:

* You do not use post-tags on the Apply Schema step (the option has no effect without a configured post-tag value).
* Your workflow treats no-op deployments as non-events and does not require a tag anchor for them.

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

#### Does this option affect deployments that apply changesets? <a href="#does-this-option-affect-deployments-that-apply-changesets" id="does-this-option-affect-deployments-that-apply-changesets"></a>

No. When one or more changesets are applied, the post-tag runs normally and no synthetic row is created. The option only changes behavior when zero changesets are applied.

#### What happens if I run the same pipeline twice with no new changesets? <a href="#what-happens-if-i-run-the-same-pipeline-twice-with-no-new-changesets" id="what-happens-if-i-run-the-same-pipeline-twice-with-no-new-changesets"></a>

On the first run, if the post-tag does not yet exist, Harness creates the synthetic row. On the second run, Harness detects the tag already exists on the latest row and skips insertion, logging a notice.

#### Is the synthetic row visible in the Harness changeset history? <a href="#is-the-synthetic-row-visible-in-the-harness-changeset-history" id="is-the-synthetic-row-visible-in-the-harness-changeset-history"></a>

Yes. The synthetic tag-marker row is synced to migration state and command execution history with a `Success` status, so it appears alongside real changeset deployments.

#### Can I roll back to a synthetic tag-marker row? <a href="#can-i-roll-back-to-a-synthetic-tag-marker-row" id="can-i-roll-back-to-a-synthetic-tag-marker-row"></a>

Yes. Rollback-to-tag treats the synthetic row as a valid rollback anchor. After rolling back to it, Harness cleans up any orphan synthetic marker rows that occurred after the target tag.

#### Does this replace the `preStartTag` that Harness creates before the deployment? <a href="#does-this-replace-the-prestarttag-that-harness-creates-before-the-deployment" id="does-this-replace-the-prestarttag-that-harness-creates-before-the-deployment"></a>

No. The `preStartTag` (created before the Apply Schema step runs) and the post-tag (created after) serve different purposes. Tag Database Changeset only affects the post-tag behavior on no-op deployments. Go to [Rollback Tags with Apply Schema](/database-devops/use-db-devops/deployment-pipeline-configuration/rollback-and-failure-strategies/using-rollback-tags.md) to understand how `preStartTag` works.
