1717use Magento \Framework \Setup \Declaration \Schema \Declaration \TableElement \ElementNameResolver ;
1818use Magento \Framework \Setup \Declaration \Schema \Diff \Diff ;
1919use Magento \Framework \Setup \Declaration \Schema \Dto \Schema ;
20+ use Magento \Framework \Setup \Declaration \Schema \Dto \Table ;
2021use Magento \Framework \Setup \Declaration \Schema \SchemaConfig ;
2122use Magento \Framework \Setup \JsonPersistor ;
2223
@@ -192,6 +193,9 @@ private function getElementsWithAutogeneratedName(Schema $schema, string $tableN
192193 $ elementType = 'index ' ;
193194 if (!empty ($ tableData [$ elementType ])) {
194195 foreach ($ tableData [$ elementType ] as $ tableElementData ) {
196+ if (!isset ($ tableElementData ['column ' ])) {
197+ continue ;
198+ }
195199 $ indexName = $ this ->elementNameResolver ->getFullIndexName (
196200 $ table ,
197201 $ tableElementData ['column ' ],
@@ -201,9 +205,30 @@ private function getElementsWithAutogeneratedName(Schema $schema, string $tableN
201205 }
202206 }
203207
208+ $ constraintName = $ this ->getConstraintName ($ schema , $ table , $ tableData );
209+ if ($ constraintName ) {
210+ $ declaredStructure += $ constraintName ;
211+ }
212+
213+ return $ declaredStructure ;
214+ }
215+
216+ /**
217+ * @param Schema $schema
218+ * @param Table $table
219+ * @param array $tableData
220+ * @return array
221+ */
222+ private function getConstraintName (Schema $ schema , Table $ table , array $ tableData ): array
223+ {
224+ $ declaredStructure = [];
225+
204226 $ elementType = 'constraint ' ;
205227 if (!empty ($ tableData [$ elementType ])) {
206228 foreach ($ tableData [$ elementType ] as $ tableElementData ) {
229+ if (!isset ($ tableElementData ['referenceTable ' ])) {
230+ continue ;
231+ }
207232 if ($ tableElementData ['type ' ] === 'foreign ' ) {
208233 $ referenceTable = $ schema ->getTableByName ($ tableElementData ['referenceTable ' ]);
209234 $ column = $ table ->getColumnByName ($ tableElementData ['column ' ]);
@@ -216,6 +241,9 @@ private function getElementsWithAutogeneratedName(Schema $schema, string $tableN
216241 $ referenceColumn
217242 ) : null ;
218243 } else {
244+ if (!isset ($ tableElementData ['column ' ])) {
245+ continue ;
246+ }
219247 $ constraintName = $ this ->elementNameResolver ->getFullIndexName (
220248 $ table ,
221249 $ tableElementData ['column ' ],
0 commit comments