Background
I have a relatively new Grails project using 3.0.14. I want to integrate Liquibase for database migration through the Database Migration Plugin (2.0.0.RC4).
So far I have a fairly large domain model that I used the plugin to “seed” the source change log. This is straight from the documents and works as intended:
grails dbm-generate-gorm-changelog changelog.groovy
What I'm trying to check / get work right now is a team dbm-gorm-diffthat will accept the changes in the domain model and create a list of changes that can be applied. Here I run into problems.
Grails documentation suggests removing the block dbCreatefrom the data source to ensure that Hibernate does not perform the update and that Liquibase can adopt. Great, exactly what I want.
Problem
When I delete dbCreate, Grails / hibernate still seems to update the database before the Database Migration plugin can execute diff. When running diff, it's too late to see the changes, so there is no valid data in the change lists.
Config
dataSource:
pooled: true
jmxExport: true
driverClassName: org.h2.Driver
username: sa
password:
environments:
development:
dataSource:
dbCreate: verify
driverClassName: org.postgresql.Driver
dialect: org.hibernate.dialect.PostgreSQLDialect
url: jdbc:postgresql://127.0.0.1:5432/liquibase_test
username: dbuser
password: dbuser
logSql: false
formatSql: true
(I know dbCreate is installed for verification. More on this later)
Steps taken
- Create a new postgres database -
dbcreate -U dbuser liquibase_test - Run the source change log in the new database -
grails dbm-update - Verify that the database is now up to date and verify that the
select * from databasechangelognumber of changes inchangelog.groovy Add a new simple domain class:
class TestDomain {
int testInt
}
, diff - grails dbm-gorm-diff add-simple-domain.groovy. :
:DataModel:dbmGormDiff
Command execution error: liquibase.command.CommandExecutionException: java.lang.NullPointerException
DataModel:dbmGormDiff FAILED
dbCreate: verify
, :
- ,
add-simple-domain.groovy, , . ( /, , ). - (!?) ( PgAdmin)
databasechangelog
, , . /, . - ?
NullPointer , , liquibase/ext/hibernate/snapshot/ForeignKeySnapshotGenerator.java:45, ( tablePerHierarchy false ). .
# 2
Github tablePerHierarchy NPE: https://github.com/grails-plugins/grails-database-migration/issues/68