@@ -124,18 +124,19 @@ public function makeMigration()
124124 $ constraints = trim (implode ($ eol . $ indent12 , $ this ->formatConstraints ())) . $ eol ;
125125 $ tableCollationAndCharset = trim (implode ($ eol . $ indent12 , $ this ->formatTableCollationAndCharset ())) . $ eol ;
126126 $ extras = trim (implode ($ eol . $ indent8 , $ this ->formatExtras ())) . $ eol ;
127- $ foreign = trim (implode ($ eol . $ indent12 , $ this ->formatForeign ())) . $ eol ;
128- $ foreignDrop = trim (implode ($ eol . $ indent12 , $ this ->formatForeignDrop ())) . $ eol ;
129- if ($ this ->hasForeign == "true " ) {
130- $ className = 'AddFkTo ' . $ this ->studly ($ this ->tableName ) . 'Table ' ;
127+
128+ if ($ this ->hasForeign === "true " ) {
129+ $ foreign = trim (implode ($ eol . $ indent12 , $ this ->formatForeign ())) . $ eol ;
130+ $ foreignDrop = trim (implode ($ eol . $ indent12 , $ this ->formatForeignDrop ())) . $ eol ;
131+ $ className = 'AddForeignKeyTo ' . $ this ->studly ($ this ->tableName ) . 'Table ' ;
131132 $ output = file_get_contents (__DIR__ . '/foreign_key.stub ' );
132133 $ output = str_replace (
133134 [
134135 ':VERSION: ' ,
135136 'DummyClass ' ,
136137 'DummyTable ' ,
137138 "// foreign \n" ,
138- "// foreignDrop \n" ,
139+ "// foreignDrop \n" ,
139140 ],
140141 [
141142 $ this ->version ,
@@ -190,7 +191,6 @@ public function formatForeign()
190191 foreach ($ rows as $ row ) {
191192 list ($ table , $ colName , $ constName , $ refTable , $ refColumnName ) = explode ("\t" ,
192193 $ row , 5 );
193- $ fields [] = '$table->unsignedBigInteger( \'' . trim ($ colName ) .'\')->change(); ' ;
194194 $ fields [] = '$table->foreign( \'' . trim ($ colName ) .'\')->references( \'' . trim ($ refColumnName ) .'\')->on( \'' . trim ($ refTable ) .'\'); ' ;
195195 }
196196 return array_filter ($ fields );
@@ -206,7 +206,6 @@ public function formatForeignDrop()
206206 foreach ($ rows as $ row ) {
207207 list ($ table , $ colName , $ constName , $ refTable , $ refColumnName ) = explode ("\t" ,
208208 $ row , 5 );
209- //$table->dropForeign('local_table_foreign_id_foreign');
210209 $ fields [] = '$table->dropForeign( \'' . trim ($ table ) .'_ ' . trim ($ colName ) .'_foreign \'); ' ;
211210 }
212211 return array_filter ($ fields );
@@ -312,7 +311,6 @@ public function buildStructure()
312311 }
313312
314313 // look for id primary key
315-
316314 if (
317315 array_key_exists ('id ' , $ this ->structure )
318316 && $ this ->structure ['id ' ]['method ' ] === 'integer '
@@ -395,7 +393,7 @@ public function formatStructure()
395393 }
396394
397395 // If isn't empty, set the comment
398- if ($ data ['comment ' ] !== '' ) {
396+ if ($ data ['comment ' ] !== '' || $ data [ ' comment ' ] !== null ) {
399397 $ temp .= '->comment( \'' . addslashes ($ data ['comment ' ]) . '\') ' ;
400398 }
401399
@@ -445,7 +443,7 @@ public function buildKeys()
445443 $ primaryColumn = reset ($ primary ['columns ' ]);
446444 $ field = $ this ->structure [$ primaryColumn ];
447445 // and that column is an "increments" field ...
448- if (isset ($ field ['autoIncrement ' ]) && $ field ['autoIncrement ' ] == ' 1 ' ) {
446+ if (isset ($ field ['args ' ][ ' autoIncrement ' ]) && $ field ['args ' ][ ' autoIncrement ' ] === ' true ' ) {
449447 // then don't build the primary key, since Laravel takes care of it
450448 unset($ this ->keys ['PRIMARY ' ]);
451449 }
0 commit comments