A lightweight database migration tool built with Java 21, picocli, and SLF4J.
- Java 21 Modernization: Uses Records, Sealed Interfaces, and modern APIs like
HexFormat. - Migration Locking: Prevents concurrent migrations from multiple instances using a database-level lock.
- Robust CLI: Powered by
picoclifor easy parameter handling and help. - Logging: SLF4J with Logback for production-grade logging.
- Checksum Validation: Ensures migration files haven't changed after being applied.
- Java 21 or higher.
- MySQL Database.
Run the migrator as an executable JAR with a subcommand:
java -jar simple-db-migrator.jar migrate -u <jdbc_url> -user <username> -p -m <migrations_path>java -jar simple-db-migrator.jar rollback -u <jdbc_url> -user <username> -p -m <migrations_path> --steps 1-u, --url: The JDBC connection URL (e.g.,jdbc:mysql://localhost:3306/mydb).-user, --username: Database username.-p, --password: Database password (interactive prompt).-m, --migrations: Path to the migrations directory (default:src/main/resources/migrations).-s, --steps: (Rollback only) Number of migrations to undo (default: 1).
- Action:
V<Version>__<Description>.sql(Example:V1__create_users.sql) - Rollback:
V<Version>__<Description>.rollback.sql(Example:V1__create_users.rollback.sql)
Run ./gradlew test to execute the full testing suite (includes H2 integration tests).