when defining a unique constraint for a domain class, grails generates for the database a constraint-name which is based on the property name. When using Postgres as a database the name will be 'unique_language' for the following constraint definition.
static constraints = {
language nullable: false, unique: 'product'
}
When I now have a second domain class which has also a unique constraint on a property with the same name, grails will again create a database constraint with the name 'unique_language'. The problem is, that for Postgres the name for a unique constraint must also be unique for the database schema. This means in our case that the second constraint is not applied to the database.
Is there a way to customize or define the unique index names?
I was looking if it is possible to enhance the NamingStrategy, but I couldn't find a point where to do the changes.
We are currently using grails 2.4.4
This issue was fixed in Grails 3.1.0.RC2: https://github.com/grails/grails-data-mapping/issues/623