Skip to content

A Spring Boot CLI utility to test and rollback specific Liquibase changesets against Oracle DB before committing to production. Useful for developers and CI pipelines to validate migrations and prevent database corruption.

Notifications You must be signed in to change notification settings

vishunit/liquibase-changeset-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 

Repository files navigation

Liquibase ChangeSet Validator

A Spring Boot utility to validate and test Liquibase changesets locally before committing to production environments.

This tool helps prevent issues caused by directly running Liquibase on production branches (like master) without proper testing.
It supports rollback verification and runs against any supported DB β€” currently configured for Oracle.

πŸš€ Features

  • βœ… Run and validate a specific changeset from your changelog file
  • πŸ” Rollback the last executed changeset for safety testing
  • πŸ§ͺ Ideal for testing migrations locally before merge/push
  • πŸ“¦ Simple Spring Boot CLI runner

πŸ›  Setup

πŸ”§ Requirements

  • Java 17 or higher
  • Maven 3.x
  • Oracle DB (default: localhost:1521/xe)
  • Oracle JDBC Driver (ojdbc11) must be installed locally if not available in a public Maven repo

βš™οΈ Configuration

Edit src/main/resources/application.properties:

spring.datasource.url=jdbc:oracle:thin:@localhost:1521:xe spring.datasource.username=your_oracle_user spring.datasource.password=your_oracle_password spring.datasource.driver-class-name=oracle.jdbc.OracleDriver

spring.liquibase.enabled=false

liquibase.changelog=db/changelog/master.xml liquibase.changeset.id=create_user_table liquibase.rollback.enabled=true

▢️ Usage

Run from IDE or CLI:

./mvnw spring-boot:run

Or build and run:

mvn clean package java -jar target/liquibase-changeset-validator-0.0.1-SNAPSHOT.jar

πŸ§ͺ What It Does

  • Applies the changeset create_user_table from master.xml
  • Logs execution success or failure
  • If rollback is enabled, it will attempt to roll back the last executed changeset
  • Useful for CI, pre-merge hooks, or local validation

πŸ“ Example Changelog

πŸ“Œ Notes

  • rollback(1) is used internally to revert the last executed changeset
  • Liquibase rollback by changeSetId does not exist; it's either rollback by tag or step count
  • This tool helps reduce manual DB fixes due to untested migrations

βœ… Planned Improvements

  • CLI argument support for changeset ID / changelog path
  • Docker Compose setup with Oracle XE for easier local testing
  • Git pre-commit integration

πŸ“„ License

MIT – Use it freely in your teams or CI/CD pipelines.

About

A Spring Boot CLI utility to test and rollback specific Liquibase changesets against Oracle DB before committing to production. Useful for developers and CI pipelines to validate migrations and prevent database corruption.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages