Stream: implementers
Topic: Database Migrations - HAPI
Joshua Bell (Aug 30 2017 at 19:32):
I've created a HAPI server using the hapi-fhir-jpaserver-base as a dependency. My project is following closely with the jpaserver-example project that exists in the fhir repo. I've noticed that that project uses the hibernate auto gen mode auto
. This is not something I am comfortable using in a production environment due to its adverse results. I can't seem to find any docs or anyone else with a better migration plan for the built in hapi server. Are people really using auto
mode in their environments?
Also, after much testing and attempts at generating liquibase logs for an initial database it seems like the project is rather weird with hibernate.
For example, if you run with hibernate.ddl mode create
, and then immediately stop and run with mode validate
- it will fail to startup. This is very alarming to me personally, as that means hibernate is not validating and or updating properly when there are changes to the schema in the entity models.
Has no one released how they use HAPI in a production environment that needs more stable database migrations? I feel like I am missing something important.
Jim Steel (Aug 30 2017 at 22:20):
We use flyway for migrations, with jpa/hibernate, but not (yet) in exactly the same context as you describe
Joshua Bell (Aug 30 2017 at 22:59):
How did you generate your original initial database? Was it used hibernate create, then take a snapshot/dump of the database? I have been unsuccessful with this approach using liquibase, which is how it would normally be done. It seems to miss some index/foreign key related things.
Jim Steel (Aug 31 2017 at 06:29):
Yeah. We switch it to update to create it, turn on the hibernate sql logging to get the table/constraint definitions (or pull them out of the database itself) to get the migrations, then turn it back to validate mode. (still need to test the migrations on different databases, since the sql often isn't portable)
Jim Steel (Aug 31 2017 at 06:29):
its finicky
Jim Steel (Aug 31 2017 at 06:31):
i think the initial database schema we pulled out of the database itself, rather than relying on the hibernate ddl logging
Joshua Bell (Aug 31 2017 at 20:30):
@Jim Steel Did you guys end up just turning ddl auto mode to none
? I would of liked to use validate
mode, but it seems that doesn't even properly work on it's own (if you use create mode then validate immediately after it fails, seems like a bad thing with the base jpa server and how it uses hibernate)
Jim Steel (Sep 06 2017 at 00:04):
No, we still use validate
. Once again, though, we don't use HAPI's base JPA server, so I can't comment on how it uses hibernate.
Last updated: Apr 12 2022 at 19:14 UTC