Prefer index name when mapping unique constraint errors

When using migrations to create indexes instead of sync or when unique
index name has fields with underscores (was problem at least with
postgres implementation) then it was not possible to set custom error
message, because mapping the error thrown from database always failed.
Fixed by using indexName always for mapping the error if possible.