ObjectDB ObjectDB

Adding new unique columns

#1

What is the best practice for when you need to add a new unique column to an existing database?

Simply adding the column with the @Unique annotation will result in "Attempt to reuse an existing value (null)", so the only option I can surmise is to add the column, update all existing entries, THEN add the @Unique constraint.  I'm hoping there's a better way, like providing a means to generate values when the existing record is null.

edit
delete
#2

> so the only option I can surmise is to add the column, update all existing entries, THEN add the @Unique constraint.

This is indeed the only option, otherwise you will break the unique constraint with multiple objects with the same null value for the field.

ObjectDB Support
edit
delete

Reply

To post on this website please sign in.