Grails Database-Migration Plugin - Where's my diff?

TL;DR: In your application.yml or equivalent, set your datasource's dbCreate to "none".

While setting up the Grails database-migration plugin in a new Grails 3.1.7 project, I encountered some strange behavior when running dbm-gorm-diff. The command seemed to be rendering an empty changeSet, even after making multiple changes to my domain class. Searching the internet, I came across several instances of similar issues, such as this post from StackOverflow.

When watching my database during execution of dbm-gorm-diff, I noted that the new columns were in fact showing up, leading me to suspect the problem was that the database and the domain model were in sync by the time the diff ran, resulting in my empty changeset script. I had removed the dbCreate field from my application.yml file, but the behavior seemed to be the same as if I had specified dbCreate: update.

Thanks to a suggestion from my OCI colleague James Kleeh, I got past this issue by setting the dbCreate of my datasource to "none". Apparently Hibernate's default behavior is essentially the same as "update", so removing the property doesn't prevent the normal "update on start" behavior in a Grails app.

Zachary Klein

Zachary Klein

I'm on the Grails Team at OCI. This blog is just a place to record tips or workarounds I've found useful while working with Groovy, Grails, Gradle, and associated oddities.