db
db copied to clipboard
Unique indexes can be loaded in 3 different ways
Unique indexes can be loaded in 3 different ways:
Schema::loadTableConstraints(): Constraint[]<-AbstractSchema::getTableUniques()Schema::loadTableIndexes(): IndexConstraint[]<-AbstractSchema::getTableIndexes()with check$index->isUnique()Schema::findUniqueIndexes(): array<-SchemaInterface::findUniqueIndexes()
PgSQL https://github.com/yiisoft/db-pgsql/blob/535975396d865da6cb15ed7bee5648c27a9b7360/src/Schema.php#L894 https://github.com/yiisoft/db-pgsql/tree/535975396d865da6cb15ed7bee5648c27a9b7360/src/Schema.php#L357 https://github.com/yiisoft/db-pgsql/tree/535975396d865da6cb15ed7bee5648c27a9b7360/src/Schema.php#L630
MySQL https://github.com/yiisoft/db-mysql/blob/4dd4e13502a0f047627c398854fc733a41054370/src/Schema.php#L618 https://github.com/yiisoft/db-mysql/blob/4dd4e13502a0f047627c398854fc733a41054370/src/Schema.php#L770 https://github.com/yiisoft/db-mysql/blob/4dd4e13502a0f047627c398854fc733a41054370/src/Schema.php#L158
Suggestion
- Load all unique indexes include primary key in
getTableUniques() - Mark as
@deprecatedSchemaInterface::findUniqueIndexes(): arrayusegetTableUniques()instead - Load all indexes
loadTableIndexes()and unique indexes in one way- get uniques from
getTableIndexes()with check$index->isUnique() - or load all indexes together with uniques as in SQLite
Schema::loadTableConstraints()in one or more queries
- get uniques from
Related with https://github.com/yiisoft/db/blob/12b89274270adc85603348a4d27e8c7d97fad617/src/QueryBuilder/AbstractDMLQueryBuilder.php#L342-L359
Fixed