jhipster --version
5.3.4
I'm evaluating JHipster and am testing how it handles database DDL modifications. In my test I created a Jhipster project and then ran jhipster import-jdl model.jh
. JHipster generated all the integration test and everything looked good. So I deployed to production. But then I realized that I defined the wrong relationship between a set of entities. The original model.jh
file declared a one-to-many
relationship when I meant to declare a many-to-one
relationship.
In order to fix this relationship I tried three approaches. First I tried to correct the relationship in the model.jh
file and rerun jhipster import-jdl
. This made the correct changes that I need, except that it overwrote the liquibase changelog files instead of creating a new changelog entry containing just the delta.
So I reverted that change, and tried to use the entity sub generator. It too modified the original changelog files rather than creating a delta changelog file. So I reverted those changes to try another approach.
I made the changes to the entities manually, and then used mvn liquibase:diff
. This approach came the closest to what I needed. It did create a new changelog rather than updating the original files. But, the new changelog was trying to change way more than just the column associated with the relationship. It was trying to change datatypes on several non-related columns in the table. It removed remarks/comments from existing columns. In short, it was basically redefining the whole table from scratch with way more changes than are necessary for the small change I was trying to make. I ended up reverting on this approach too.
So, my question is, for those of you who are experienced users of JHipster and liquibase, how to you modify your entities after they have already been in use in production? Do you just create your changelogs manually, or is there a good way to auto generate them?
master.xml
)./mvnw compile liquibase:diff
./gradlew compileJava liquibaseDiffChangelog -PrunList=diffLog
master.xml
Steps 3-5 are documented in JHipster's "Using a Database" docs. Note that these steps only work if you are using a local database in dev, it currently does not work with H2.
You can see these steps as commits in this branch on Github.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With