@@ -136,15 +136,17 @@ protected function _alterTable(string $alterType, string $table, $processedField
136136 {
137137 // Handle DROP here
138138 if ($ alterType === 'DROP ' ) {
139+ $ columnNamesToDrop = $ processedFields ;
140+
139141 // check if fields are part of any indexes
140142 $ indexData = $ this ->db ->getIndexData ($ table );
141143
142144 foreach ($ indexData as $ index ) {
143- if (is_string ($ processedFields )) {
144- $ processedFields = explode (', ' , $ processedFields );
145+ if (is_string ($ columnNamesToDrop )) {
146+ $ columnNamesToDrop = explode (', ' , $ columnNamesToDrop );
145147 }
146148
147- $ fld = array_intersect ($ processedFields , $ index ->fields );
149+ $ fld = array_intersect ($ columnNamesToDrop , $ index ->fields );
148150
149151 // Drop index if field is part of an index
150152 if ($ fld !== []) {
@@ -155,7 +157,7 @@ protected function _alterTable(string $alterType, string $table, $processedField
155157 $ fullTable = $ this ->db ->escapeIdentifiers ($ this ->db ->schema ) . '. ' . $ this ->db ->escapeIdentifiers ($ table );
156158
157159 // Drop default constraints
158- $ fields = implode (', ' , $ this ->db ->escape ((array ) $ processedFields ));
160+ $ fields = implode (', ' , $ this ->db ->escape ((array ) $ columnNamesToDrop ));
159161
160162 $ sql = <<<SQL
161163 SELECT name
@@ -172,7 +174,7 @@ protected function _alterTable(string $alterType, string $table, $processedField
172174
173175 $ sql = 'ALTER TABLE ' . $ fullTable . ' DROP ' ;
174176
175- $ fields = array_map (static fn ($ item ) => 'COLUMN [ ' . trim ($ item ) . '] ' , (array ) $ processedFields );
177+ $ fields = array_map (static fn ($ item ) => 'COLUMN [ ' . trim ($ item ) . '] ' , (array ) $ columnNamesToDrop );
176178
177179 return $ sql . implode (', ' , $ fields );
178180 }
0 commit comments