I think you can consider these cases:
- Multiple different type of indexes on the same key set --> Exception if MongoDB throws exception
- Multiple unique indexes with different names all defined with @Index(columnList="email", unique = "true", name=) --> throw an exception because MongoDB throws an exception (we need a test)
- @UniqueConstraint(columnNames = "email") and @Index(columnList = "email", unique=true)` -> Just create the constraint as if only @Index(...) were present, no need to log warning because there is no difference from the MongoDB side. It's just the JPA way that doesn't work well for MongoDB because an index and a constraint are the same thing while, in other datastore, could be two different things.
Not sure how feasable this is but it's the thing that makes more sense to me. We probably need to keep track if an index must be created because is a unique constraint or is an index. We also need additional test cases covering all these situations. If it gets too complicated or unfeasable we can simplify it. |