@@ -144,6 +144,25 @@ public function compileAdd(Blueprint $blueprint, Fluent $command)
144
144
})->all ();
145
145
}
146
146
147
+ /**
148
+ * Compile a rename column command.
149
+ *
150
+ * @param \Illuminate\Database\Schema\Blueprint $blueprint
151
+ * @param \Illuminate\Support\Fluent $command
152
+ * @param \Illuminate\Database\Connection $connection
153
+ * @return array|string
154
+ */
155
+ public function compileRenameColumn (Blueprint $ blueprint , Fluent $ command , Connection $ connection )
156
+ {
157
+ return $ connection ->usingNativeSchemaOperations ()
158
+ ? sprintf ('alter table %s rename column %s to %s ' ,
159
+ $ this ->wrapTable ($ blueprint ),
160
+ $ this ->wrap ($ command ->from ),
161
+ $ this ->wrap ($ command ->to )
162
+ )
163
+ : parent ::compileRenameColumn ($ blueprint , $ command , $ connection );
164
+ }
165
+
147
166
/**
148
167
* Compile a unique key command.
149
168
*
@@ -286,17 +305,26 @@ public function compileRebuild()
286
305
*/
287
306
public function compileDropColumn (Blueprint $ blueprint , Fluent $ command , Connection $ connection )
288
307
{
289
- $ tableDiff = $ this ->getDoctrineTableDiff (
290
- $ blueprint , $ schema = $ connection ->getDoctrineSchemaManager ()
291
- );
308
+ if ($ connection ->usingNativeSchemaOperations ()) {
309
+ $ table = $ this ->wrapTable ($ blueprint );
292
310
293
- foreach ($ command ->columns as $ name ) {
294
- $ tableDiff ->removedColumns [$ name ] = $ connection ->getDoctrineColumn (
295
- $ this ->getTablePrefix ().$ blueprint ->getTable (), $ name
311
+ $ columns = $ this ->prefixArray ('drop column ' , $ this ->wrapArray ($ command ->columns ));
312
+
313
+ return collect ($ columns )->map (fn ($ column ) => 'alter table ' .$ table .' ' .$ column
314
+ )->all ();
315
+ } else {
316
+ $ tableDiff = $ this ->getDoctrineTableDiff (
317
+ $ blueprint , $ schema = $ connection ->getDoctrineSchemaManager ()
296
318
);
297
- }
298
319
299
- return (array ) $ schema ->getDatabasePlatform ()->getAlterTableSQL ($ tableDiff );
320
+ foreach ($ command ->columns as $ name ) {
321
+ $ tableDiff ->removedColumns [$ name ] = $ connection ->getDoctrineColumn (
322
+ $ this ->getTablePrefix ().$ blueprint ->getTable (), $ name
323
+ );
324
+ }
325
+
326
+ return (array ) $ schema ->getDatabasePlatform ()->getAlterTableSQL ($ tableDiff );
327
+ }
300
328
}
301
329
302
330
/**
0 commit comments