@@ -110,6 +110,31 @@ public function dropDatabase(string $dbName): bool
110110 return true ;
111111 }
112112
113+ /**
114+ * @param list<string>|string $columnNames
115+ *
116+ * @throws DatabaseException
117+ */
118+ public function dropColumn (string $ table , $ columnNames ): bool
119+ {
120+ $ columns = is_array ($ columnNames ) ? $ columnNames : array_map (trim (...), explode (', ' , $ columnNames ));
121+ $ result = (new Table ($ this ->db , $ this ))
122+ ->fromTable ($ this ->db ->DBPrefix . $ table )
123+ ->dropColumn ($ columns )
124+ ->run ();
125+
126+ if (! $ result && $ this ->db ->DBDebug ) {
127+ throw new DatabaseException (sprintf (
128+ 'Failed to drop column%s "%s" on "%s" table. ' ,
129+ count ($ columns ) > 1 ? 's ' : '' ,
130+ implode ('", " ' , $ columns ),
131+ $ table ,
132+ ));
133+ }
134+
135+ return $ result ;
136+ }
137+
113138 /**
114139 * @param array|string $processedFields Processed column definitions
115140 * or column names to DROP
@@ -121,17 +146,6 @@ public function dropDatabase(string $dbName): bool
121146 protected function _alterTable (string $ alterType , string $ table , $ processedFields )
122147 {
123148 switch ($ alterType ) {
124- case 'DROP ' :
125- $ columnNamesToDrop = $ processedFields ;
126-
127- $ sqlTable = new Table ($ this ->db , $ this );
128-
129- $ sqlTable ->fromTable ($ table )
130- ->dropColumn ($ columnNamesToDrop )
131- ->run ();
132-
133- return '' ; // Why empty string?
134-
135149 case 'CHANGE ' :
136150 $ fieldsToModify = [];
137151
0 commit comments