I have an application where Hibernate creates all my table schemata whenever the application is run on a machine for the first time. This works nicely.
Now I was howeve
We had the same problem with our Java/Hibernate project, and did not want any code duplication effort. Hibernate "update" feature is not reliable at all, LiquidBase is better but not 100% fool proof either. In the end we developed a simple script to manage the following process:
A key command in our script reads like the following:
${LIQB_COMMAND} ${PREV_DB_OPTIONS} --changeLogFile=${LIQB_CHGLOG_FILE_NEW} \
diffChangeLog \
--referenceUsername=${DEV_DB_USER} \
--referencePassword=${DEV_DB_PWD} \
--referenceDriver=com.mysql.jdbc.Driver \
--referenceUrl=${DEV_DB_URL}
This way, our migration process is quite reliable and you don't write the schema code twice. There is a manual review of the generated change set in XML, but most of the time there is no problem, and it sure is much easier than manually writing the schema change operations.