6
6
7
7
use Yiisoft \Db \Constant \ColumnType ;
8
8
use 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 ;
12
12
use Yiisoft \Db \Driver \Pdo \AbstractPdoSchema ;
13
13
use Yiisoft \Db \Exception \NotSupportedException ;
14
14
use Yiisoft \Db \Helper \DbArrayHelper ;
@@ -165,15 +165,15 @@ protected function loadTableSchema(string $name): TableSchemaInterface|null
165
165
return null ;
166
166
}
167
167
168
- protected function loadTablePrimaryKey (string $ tableName ): IndexConstraint |null
168
+ protected function loadTablePrimaryKey (string $ tableName ): Index |null
169
169
{
170
- /** @var IndexConstraint |null */
170
+ /** @var Index |null */
171
171
return $ this ->loadTableConstraints ($ tableName , self ::PRIMARY_KEY );
172
172
}
173
173
174
174
protected function loadTableForeignKeys (string $ tableName ): array
175
175
{
176
- /** @var ForeignKeyConstraint [] */
176
+ /** @var ForeignKey [] */
177
177
return $ this ->loadTableConstraints ($ tableName , self ::FOREIGN_KEYS );
178
178
}
179
179
@@ -183,8 +183,8 @@ protected function loadTableIndexes(string $tableName): array
183
183
SELECT
184
184
"ic"."relname" AS "name",
185
185
"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 "
188
188
FROM "pg_class" AS "tc"
189
189
INNER JOIN "pg_namespace" AS "tcns"
190
190
ON "tcns"."oid" = "tc"."relnamespace"
@@ -218,17 +218,17 @@ protected function loadTableIndexes(string $tableName): array
218
218
* array{
219
219
* name: string,
220
220
* column_name: string,
221
- * index_is_unique : bool,
222
- * index_is_primary : bool
221
+ * is_unique : bool,
222
+ * is_primary_key : bool
223
223
* }
224
224
* > $index
225
225
*/
226
226
foreach ($ indexes as $ name => $ index ) {
227
- $ result [] = new IndexConstraint (
227
+ $ result [] = new Index (
228
228
$ name ,
229
229
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 ' ],
232
232
);
233
233
}
234
234
@@ -237,13 +237,13 @@ protected function loadTableIndexes(string $tableName): array
237
237
238
238
protected function loadTableUniques (string $ tableName ): array
239
239
{
240
- /** @var IndexConstraint [] */
240
+ /** @var Index [] */
241
241
return $ this ->loadTableConstraints ($ tableName , self ::UNIQUES );
242
242
}
243
243
244
244
protected function loadTableChecks (string $ tableName ): array
245
245
{
246
- /** @var CheckConstraint [] */
246
+ /** @var Check [] */
247
247
return $ this ->loadTableConstraints ($ tableName , self ::CHECKS );
248
248
}
249
249
@@ -717,9 +717,9 @@ private function loadColumn(array $info): ColumnInterface
717
717
* - uniques
718
718
* - checks
719
719
*
720
- * @return CheckConstraint []|ForeignKeyConstraint []|IndexConstraint|IndexConstraint []|null Constraints.
720
+ * @return Check []|ForeignKey []|Index|Index []|null Constraints.
721
721
*/
722
- private function loadTableConstraints (string $ tableName , string $ returnType ): array |IndexConstraint |null
722
+ private function loadTableConstraints (string $ tableName , string $ returnType ): array |Index |null
723
723
{
724
724
$ sql = <<<SQL
725
725
SELECT
@@ -788,26 +788,27 @@ private function loadTableConstraints(string $tableName, string $returnType): ar
788
788
*/
789
789
foreach ($ names as $ name => $ constraint ) {
790
790
match ($ type ) {
791
- 'p ' => $ result [self ::PRIMARY_KEY ] = new IndexConstraint (
791
+ 'p ' => $ result [self ::PRIMARY_KEY ] = new Index (
792
792
$ name ,
793
793
array_column ($ constraint , 'column_name ' ),
794
794
true ,
795
795
true ,
796
796
),
797
- 'f ' => $ result [self ::FOREIGN_KEYS ][] = new ForeignKeyConstraint (
797
+ 'f ' => $ result [self ::FOREIGN_KEYS ][] = new ForeignKey (
798
798
$ name ,
799
799
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 ' ],
801
802
array_values (array_unique (array_column ($ constraint , 'foreign_column_name ' ))),
802
- $ actionTypes [$ constraint [0 ]['on_update ' ]] ?? null ,
803
803
$ actionTypes [$ constraint [0 ]['on_delete ' ]] ?? null ,
804
+ $ actionTypes [$ constraint [0 ]['on_update ' ]] ?? null ,
804
805
),
805
- 'u ' => $ result [self ::UNIQUES ][] = new IndexConstraint (
806
+ 'u ' => $ result [self ::UNIQUES ][] = new Index (
806
807
$ name ,
807
808
array_column ($ constraint , 'column_name ' ),
808
809
true ,
809
810
),
810
- 'c ' => $ result [self ::CHECKS ][] = new CheckConstraint (
811
+ 'c ' => $ result [self ::CHECKS ][] = new Check (
811
812
$ name ,
812
813
array_column ($ constraint , 'column_name ' ),
813
814
$ constraint [0 ]['check_expr ' ],
0 commit comments