
Database rollbacks are often overlooked, but testing undo migrations is key to safe deployments. In this blog, we’ll explore how Harness Database DevOps and Liquibase help automate rollback testing so you can deliver database changes with confidence.
When teams think about DevOps, automation usually starts with application code. We build, test, deploy, and even roll back apps with high confidence. But when it comes to databases, the story is different. Rollbacks are tricky, often skipped, and rarely tested before hitting production.
This is where undo migrations come in. And more importantly, this is where Harness Database DevOps, combined with Liquibase, makes life easier.
What Are Undo Migrations and Why Test Them?
Undo migrations (sometimes called rollbacks) are the scripts that reverse database schema changes. For example:
- A forward migration might add a new column.
- It's undo migration would drop that column.
Simple enough in theory. But in reality, untested undo migrations often fail because of:
- Schema drift (the database isn’t in the exact state you expect).
- Dependencies between changesets.
- Overlooked edge cases (constraints, indexes, data loss).
That’s why testing undo migrations matters. The same way we wouldn’t ship application code without unit tests, we shouldn’t deploy database changes without validating that rollbacks work.
How Harness Database DevOps Helps?
Harness Database DevOps brings CI/CD discipline to your database pipelines. Instead of running ad-hoc SQL scripts, you can:
- Orchestrate schema changes with Liquibase.
- Run pre-deployment evaluations automatically.
- Roll forward or roll back with confidence.
The biggest advantage is consistency. Every pipeline run follows the same steps, and every rollback is tested before it can cause trouble in production.
A Simple Workflow
One of our customers shared how they test undo migrations in their Harness pipeline. Their approach is smart, yet simple:
- First, they run a Liquibase history check. If the same build version has already been applied to the database, the pipeline fails right away, no surprises later.
- Next, they take a database snapshot and store it.
- They then apply the schema, mark all changesets as executed, and immediately roll it back.
- Another snapshot is taken, and the two are compared.
If the snapshots match, it proves the rollback worked exactly as intended. If not, the pipeline fails, and the issue can be fixed before deployment. Here’s a simplified flow:
[Liquibase History Check]
↓
[Take DB Snapshot]
↓
[Apply Schema + Mark Ran]
↓
[Rollback Changes]
↓
[Take New Snapshot]
↓
[Compare Snapshots] ──> Pass ✅ / Fail ❌
This high-level flow shows how rollback testing can be automated without slowing down delivery.
Implementing Undo Testing in Harness
So how can you set this up in Harness Database DevOps?
- Liquibase integration: Harness can run Liquibase commands like history, update, and rollback as part of your pipeline stages.
- Snapshot management: Use shared volumes or artifact stores to keep database snapshots for comparison.
- Automated validation: Add a step that compares the “before” and “after” snapshots. If they don’t match, Harness automatically fails the pipeline.
By adding these steps into your pre-deployment evaluation, you ensure that every change is reversible before it ever touches production.
Conclusion
Database rollbacks don’t have to be scary. With Harness Database DevOps, you can bring the same automation and testing discipline that you already use for application code. Undo migrations, once a source of stress for DBAs and developers, become just another automated check in your CI/CD pipeline. And with tools like Liquibase, you can trust that schema changes are applied and rolled back safely, every single time.
FAQs
1. Do I need to write undo migrations for every change?
Not always. Some changes are irreversible (like dropping a table with data). But wherever possible, undo migrations are strongly recommended to make deployments safer.
2. What happens if my rollback script fails in Harness?
If the rollback fails, the pipeline stops immediately. This ensures you catch the error early in a controlled environment instead of in production.
3. How does snapshot comparison work?
Harness stores database snapshots (before and after applying + rolling back changes) and compares them. If the schema doesn’t match, the pipeline fails.
4. Can I test rollbacks in production?
It’s best to test rollbacks in a staging or pre-production environment. The automated checks should happen before deployment so production never sees a broken rollback.
5. Is Liquibase required for this setup?
Harness Database DevOps integrates natively with Liquibase, making it the recommended tool for database change management. However, the same concepts can be applied with other migration frameworks such as Flyway. For example, Flyway users can leverage the flyway snapshot command in a similar way to the Liquibase snapshot command.