@@ -187,7 +187,7 @@ protected function addForeignKey(string $table, string $referenceTable, array $c
187187 $ sql .= ' ON UPDATE ' . $ onUpdate ;
188188 }
189189
190- $ this ->alters [ $ table][] = $ sql ;
190+ $ this ->addAlter ( $ table, $ sql) ;
191191
192192 return true ;
193193 }
@@ -228,7 +228,7 @@ protected function addPrimaryKey(string $table, array $fields) : bool
228228 {
229229 $ this ->dropPrimaryKey ($ table );
230230 $ keys = \implode ('`, ` ' , $ fields );
231- $ this ->alters [ $ table] = [ "ADD PRIMARY KEY (` {$ keys }`) " ] ;
231+ $ this ->addAlter ( $ table, "ADD PRIMARY KEY (` {$ keys }`) " ) ;
232232
233233 return true ;
234234 }
@@ -248,7 +248,7 @@ protected function addPrimaryKeyAutoIncrement(string $table, string $field = '',
248248 $ newFieldName = $ field ;
249249 }
250250 $ this ->dropPrimaryKey ($ table );
251- $ this ->alters [ $ table] = [ "change ` {$ field }` ` {$ newFieldName }` int NOT NULL primary key auto_increment " ] ;
251+ $ this ->addAlter ( $ table, "change ` {$ field }` ` {$ newFieldName }` int NOT NULL primary key auto_increment " ) ;
252252
253253 return true ;
254254 }
@@ -361,7 +361,7 @@ protected function dropForeignKey(string $table, string | array $columns) : bool
361361 }
362362
363363 $ sql = 'DROP FOREIGN KEY ' . $ index ;
364- $ this ->alters [ $ table][] = $ sql ;
364+ $ this ->addAlter ( $ table, $ sql) ;
365365
366366 return true ;
367367 }
@@ -500,7 +500,7 @@ protected function renameColumn(string $table, string $field, string $newName) :
500500 if ($ fieldInfo )
501501 {
502502 $ sql = "RENAME COLUMN ` {$ field }` TO ` {$ newName }` " ;
503- $ this ->alters [ $ table][] = $ sql ;
503+ $ this ->addAlter ( $ table, $ sql) ;
504504 }
505505
506506 return true ;
@@ -530,6 +530,11 @@ private function alter(string $type, string $table, string $field, string $extra
530530 $ sql .= ' ' . $ extra ;
531531 }
532532
533+ $ this ->addAlter ($ table , $ sql );
534+ }
535+
536+ private function addAlter (string $ table , $ sql ) : void
537+ {
533538 if (! isset ($ this ->alters [$ table ]))
534539 {
535540 $ this ->alters [$ table ] = [];
0 commit comments