The handling of unique constraints was somewhat improved by HHH-7797's addition of Dialect#uniqueDelegate. However, more is needed.
We need a way to handle all variations of: * unique vs. not unique * JPA @Index vs. no index * JPA @Index(unique = true) vs. @Index(unique = true)
Further, some DBs automatically create an index for a constraint (see http://www.postgresql.org/docs/8.0/static/indexes-unique.html as an example). Where that's not the case, explicitly create both. Handling needs tied to the Dialect.
suggestion: Dialect#applyConstraints( table, model)
Additional requirements: * log warning if mapping/dialect would result in duplicate indices * don't assume the structure of creation commands (ex: Teradata expects "create index [name]([column]...) on [table]", not "create index [name] on [table] ([column]...)")
|