@@ -211,30 +211,24 @@ private function getElementsWithAutogeneratedName(Schema $schema, string $tableN
211
211
$ constraintName = null ;
212
212
if (isset ($ tableElementData ['type ' ], $ tableElementData ['column ' ])) {
213
213
if ($ tableElementData ['type ' ] === 'foreign ' ) {
214
- if (isset (
215
- $ tableElementData ['column ' ],
216
- $ tableElementData ['referenceTable ' ],
217
- $ tableElementData ['referenceColumn ' ]
218
- )) {
219
- $ referenceTable = $ schema ->getTableByName ($ tableElementData ['referenceTable ' ]);
220
- $ column = $ table ->getColumnByName ($ tableElementData ['column ' ]);
221
- $ referenceColumn = $ referenceTable ->getColumnByName ($ tableElementData ['referenceColumn ' ]);
222
- $ constraintName = ($ column !== false && $ referenceColumn !== false ) ?
223
- $ this ->elementNameResolver ->getFullFKName (
224
- $ table ,
225
- $ column ,
226
- $ referenceTable ,
227
- $ referenceColumn
228
- ) : null ;
229
- }
230
- } else {
231
- if (isset ($ tableElementData ['column ' ])) {
232
- $ constraintName = $ this ->elementNameResolver ->getFullIndexName (
214
+ $ column = $ table ->getColumnByName ($ tableElementData ['column ' ]);
215
+ $ referenceTable = $ schema ->getTableByName ($ tableElementData ['referenceTable ' ] ?? null );
216
+ $ referenceColumn = ($ referenceTable !== false )
217
+ ? $ referenceTable ->getColumnByName ($ tableElementData ['referenceColumn ' ] ?? null ) : false ;
218
+
219
+ $ constraintName = ($ column !== false && $ referenceColumn !== false ) ?
220
+ $ this ->elementNameResolver ->getFullFKName (
233
221
$ table ,
234
- $ tableElementData ['column ' ],
235
- $ tableElementData ['type ' ]
236
- );
237
- }
222
+ $ column ,
223
+ $ referenceTable ,
224
+ $ referenceColumn
225
+ ) : null ;
226
+ } else {
227
+ $ constraintName = $ this ->elementNameResolver ->getFullIndexName (
228
+ $ table ,
229
+ $ tableElementData ['column ' ],
230
+ $ tableElementData ['type ' ]
231
+ );
238
232
}
239
233
}
240
234
if ($ constraintName ) {
0 commit comments