hardy.ferentschik wrote:
avihaimar77 wrote:
I want to the get an idea from you how you handle in the model changes?
Does each developer that change the model need also to write the alter?
Do you work with schema comparion tools?
I agree,
hbm2ddl is great for development, but once you are in production you have no or hardly any tools support.
All projects I worked on relied on the fact that - once in production - the developers will create and maintain database migration scripts containing all required db alter commands. In one project we introduced a schema_info table a la Ruby on Rails, but the developers were responsible to update this table as part of the overall migration script. It was far off what 'rake migrate' can do for you.
So far I've only heard of LiquiBase (
http://www.liquibase.org/) as a Java based database migration tool. However, I have no idea if and how you could use it in combination with hibernate.
I wonder whether there are any plans within Hibernate to extend hibernate Tools and add more support for database migration?
I've though a bit about how LiquiBase could be integrated more closely with Hibernate.
What I would like best is a way to describe the database changes along with the database mapping. Unfortunately you run into the problem of where and how you would store your database changes. Normally all changes are appended to a change log file and can be run sequentially, but if you tried to move the change definitions to a hibernate xml file or annotations you would loose control over how they are ordered.
Even if you come up with an ordering scheme you also have the trouble of where you store changes for non-current items. For example: you originally have a mapped "password" column on a "user" table but then drop it. You will no longer have a listing in your hibernate mapping for "password", so where do you put the drop table change?
It seems to me that the best you could do is a "hbm2changelog" app which would compare what the current hibernate mappings to a database and append the changes to the LiquiBase change log file which could then be inspected and then run. LiquiBase already has a database "diff" tool and change log generator so it may be easy to integrate it with the hbm2ddl library, depending on how extensible that tool is.