The latest release of the Carbon Five Database Migration maven plugin supports a new goal: check. The check goal fails the build if the database isn’t up to date. That is, if there are pending migrations the plugin produces a clear message explaining that the database is out of date and lists the pending migrations. Run mvn test and see something like this:
[INFO] ------------------------------------------------------------------------
[INFO] Building Gearlist - Data Access
[INFO] task-segment: [test]
[INFO] ------------------------------------------------------------------------
[INFO] [db-migration:check {execution: default}]
[INFO] Checking jdbc:mysql://localhost/gearlist_test using migrations at src/main/db/migrations/.
[INFO] Loaded JDBC driver: com.mysql.jdbc.Driver
[WARNING] There are 2 pending migrations:
20100116010256_audit_tracking.sql
20100121052539_add_daily_reports.sql
Execute db-migration:migrate to apply pending migrations.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] There are 2 pending migrations, migrate your db and try again.It’s very easy to include the check goal in your build lifecycle if you’re already using the db-migration-maven-plugin.
... <build> <plugins> <plugin> <groupId>com.carbonfive.db-support</groupId> <artifactId>db-migration-maven-plugin</artifactId> <version>0.9.9-m2</version> <executions> <execution> <phase>validate</phase> <goals> <goal>check</goal> </goals> </execution> </executions> <configuration> <url>jdbc:mysql://${db.host}/${db.name}</url> <username>${db.username}</username> <password>${db.password}</password> </configuration> </plugin> </plugins> </build>
Check out the project home for additional documentation and details. There’s also a simple, complete example application showing off this configuration.
Enjoy!
Christian


did you post the updated plugin in your maven repository? I can’t find version 0.9.9-m2 in there.
thanks for the great plugin!
Jonathan,
0.9.9-m3 is the latest version, but there’s very little difference from 0.9.9-m2. Both are available in our maven repository.
Be sure to add the plugin repository:
<pluginRepositories>
<pluginRepository>
<id>c5-public-repository</id>
<name>Carbon Five Public Repository</name>
<url>http://mvn.carbonfive.com/public</url>
</pluginRepository>
</pluginRepositories>
And that you’re reference the plugin with the GAV:
<groupId>com.carbonfive.db-support</groupId>
<artifactId>db-migration-maven-plugin</artifactId>
<version>0.9.9-m3</version>
Christian