While trying to reduce the likelihood of duplicate ids
for documents, and
extending my patch to provide a proper solution for objects, I fall on a
really unexpected issue: the type of the object identifiers are Integer
where those of documents are Long. This is completely abnormal since we
have several objects per documents, and therefore we need more distinct ids
for objects than documents.
I have therefore upgraded the ids of objects to use Long, and provide an
implementation that use the lowest 64bits of an MD5 key for object in the
same way I do for documents. This implementation introduce two new
serializer: UidStringEntityReferenceSerializer and
LocalUidStringEntityReferenceSerializer.
I have also bridged the statistics that derived from objects. The new
implementation works perfectly on a new database but...
... I am unable to provide a proper migration procedure, since hibernate
cannot manage changing the types of existing columns. It does not complains
during schema update, it simply do nothing about them. And later the data
migration breaks since my hashes cannot fit in the database properly. After
thorough googling, I understand that hibernate schema updates were not made
for production use and are really limited opposed to the general idea we
had of it.
Since I am currently stucked, I propose to move ahead and use a new tool to
properly manage our database schema upgrade:
http://www.liquibase.org/
Liquibase is Apache licensed and provide a database agnostic version system
for migrating databases. It does not works like a diff tool, but more like
a patch tool, where you provide several XML description of your wanted
changes and it manage to apply or rollback there changes in an ordered
manner to upgrade the database to the latest schema.
There is several way to apply these changes and I would like to see if it
could be integrated in our current migration procedure, or at least as an
independent listener.
WDYT ?