66
77use Yiisoft \Db \Constant \ColumnType ;
88use Yiisoft \Db \Constant \ReferentialAction ;
9- use Yiisoft \Db \Constraint \CheckConstraint ;
10- use Yiisoft \Db \Constraint \ForeignKeyConstraint ;
11- use Yiisoft \Db \Constraint \IndexConstraint ;
9+ use Yiisoft \Db \Constraint \Check ;
10+ use Yiisoft \Db \Constraint \ForeignKey ;
11+ use Yiisoft \Db \Constraint \Index ;
1212use Yiisoft \Db \Driver \Pdo \AbstractPdoSchema ;
1313use Yiisoft \Db \Exception \NotSupportedException ;
1414use Yiisoft \Db \Helper \DbArrayHelper ;
@@ -165,15 +165,15 @@ protected function loadTableSchema(string $name): TableSchemaInterface|null
165165 return null ;
166166 }
167167
168- protected function loadTablePrimaryKey (string $ tableName ): IndexConstraint |null
168+ protected function loadTablePrimaryKey (string $ tableName ): Index |null
169169 {
170- /** @var IndexConstraint |null */
170+ /** @var Index |null */
171171 return $ this ->loadTableConstraints ($ tableName , self ::PRIMARY_KEY );
172172 }
173173
174174 protected function loadTableForeignKeys (string $ tableName ): array
175175 {
176- /** @var ForeignKeyConstraint [] */
176+ /** @var ForeignKey [] */
177177 return $ this ->loadTableConstraints ($ tableName , self ::FOREIGN_KEYS );
178178 }
179179
@@ -183,8 +183,8 @@ protected function loadTableIndexes(string $tableName): array
183183 SELECT
184184 "ic"."relname" AS "name",
185185 "ia"."attname" AS "column_name",
186- "i"."indisunique" AS "index_is_unique ",
187- "i"."indisprimary" AS "index_is_primary "
186+ "i"."indisunique" AS "is_unique ",
187+ "i"."indisprimary" AS "is_primary_key "
188188 FROM "pg_class" AS "tc"
189189 INNER JOIN "pg_namespace" AS "tcns"
190190 ON "tcns"."oid" = "tc"."relnamespace"
@@ -218,17 +218,17 @@ protected function loadTableIndexes(string $tableName): array
218218 * array{
219219 * name: string,
220220 * column_name: string,
221- * index_is_unique : bool,
222- * index_is_primary : bool
221+ * is_unique : bool,
222+ * is_primary_key : bool
223223 * }
224224 * > $index
225225 */
226226 foreach ($ indexes as $ name => $ index ) {
227- $ result [] = new IndexConstraint (
227+ $ result [] = new Index (
228228 $ name ,
229229 array_column ($ index , 'column_name ' ),
230- $ index [0 ]['index_is_unique ' ],
231- $ index [0 ]['index_is_primary ' ],
230+ $ index [0 ]['is_unique ' ],
231+ $ index [0 ]['is_primary_key ' ],
232232 );
233233 }
234234
@@ -237,13 +237,13 @@ protected function loadTableIndexes(string $tableName): array
237237
238238 protected function loadTableUniques (string $ tableName ): array
239239 {
240- /** @var IndexConstraint [] */
240+ /** @var Index [] */
241241 return $ this ->loadTableConstraints ($ tableName , self ::UNIQUES );
242242 }
243243
244244 protected function loadTableChecks (string $ tableName ): array
245245 {
246- /** @var CheckConstraint [] */
246+ /** @var Check [] */
247247 return $ this ->loadTableConstraints ($ tableName , self ::CHECKS );
248248 }
249249
@@ -717,9 +717,9 @@ private function loadColumn(array $info): ColumnInterface
717717 * - uniques
718718 * - checks
719719 *
720- * @return CheckConstraint []|ForeignKeyConstraint []|IndexConstraint|IndexConstraint []|null Constraints.
720+ * @return Check []|ForeignKey []|Index|Index []|null Constraints.
721721 */
722- private function loadTableConstraints (string $ tableName , string $ returnType ): array |IndexConstraint |null
722+ private function loadTableConstraints (string $ tableName , string $ returnType ): array |Index |null
723723 {
724724 $ sql = <<<SQL
725725 SELECT
@@ -788,26 +788,27 @@ private function loadTableConstraints(string $tableName, string $returnType): ar
788788 */
789789 foreach ($ names as $ name => $ constraint ) {
790790 match ($ type ) {
791- 'p ' => $ result [self ::PRIMARY_KEY ] = new IndexConstraint (
791+ 'p ' => $ result [self ::PRIMARY_KEY ] = new Index (
792792 $ name ,
793793 array_column ($ constraint , 'column_name ' ),
794794 true ,
795795 true ,
796796 ),
797- 'f ' => $ result [self ::FOREIGN_KEYS ][] = new ForeignKeyConstraint (
797+ 'f ' => $ result [self ::FOREIGN_KEYS ][] = new ForeignKey (
798798 $ name ,
799799 array_values (array_unique (array_column ($ constraint , 'column_name ' ))),
800- $ constraint [0 ]['foreign_table_schema ' ] . '. ' . $ constraint [0 ]['foreign_table_name ' ],
800+ $ constraint [0 ]['foreign_table_schema ' ],
801+ $ constraint [0 ]['foreign_table_name ' ],
801802 array_values (array_unique (array_column ($ constraint , 'foreign_column_name ' ))),
802- $ actionTypes [$ constraint [0 ]['on_update ' ]] ?? null ,
803803 $ actionTypes [$ constraint [0 ]['on_delete ' ]] ?? null ,
804+ $ actionTypes [$ constraint [0 ]['on_update ' ]] ?? null ,
804805 ),
805- 'u ' => $ result [self ::UNIQUES ][] = new IndexConstraint (
806+ 'u ' => $ result [self ::UNIQUES ][] = new Index (
806807 $ name ,
807808 array_column ($ constraint , 'column_name ' ),
808809 true ,
809810 ),
810- 'c ' => $ result [self ::CHECKS ][] = new CheckConstraint (
811+ 'c ' => $ result [self ::CHECKS ][] = new Check (
811812 $ name ,
812813 array_column ($ constraint , 'column_name ' ),
813814 $ constraint [0 ]['check_expr ' ],
0 commit comments