- πΈπ°Slovakia poker10
Indexes are created via
Schema::addIndex()
and have suffix__idx
. TheSchema::indexExists()
checks only for indexes created viaSchema::addIndex()
(and it checkspg_indexes
).Unique keys are created as constraints via
Schema::addUniqueKey()
and have suffix__key
. There is aSchema::constraintExists()
which checks for PK, FK, UK (and it checkspg_constraint
).It is true, that
pg_indexes
contains records for PK, UK, .., but I am not sure (when using our terminology - index vs unique key) if theSchema::indexExists()
should check for unique keys. Now it is separated in two functions - one for indexes, one for constraints. Otherwise would not be theSchema::constraintExists()
redundant?From older PostgreSQL docs - https://www.postgresql.org/docs/9.4/indexes-unique.html:
The use of indexes to enforce unique constraints could be considered an implementation detail that should not be accessed directly.
We are creating UK as constraints and despite the fact that there is an index created in the background, should not we treat them as constraints?
Is there a reason why the current behavior is a bug and what problems is this behavior causing (would be great to update IS with these information)? Thanks!