@@ -101,7 +101,7 @@ public function migrate(): void {
101
101
return ;
102
102
}
103
103
$ tablesToCreate = $ checker ->getNonExistingTables ();
104
- if (! \empty ($ tablesToCreate )) {
104
+ if (\count ($ tablesToCreate )> 0 ) {
105
105
$ this ->generator ->setTablesToCreate ($ tablesToCreate );
106
106
$ this ->createDatabase ($ dbName , false );
107
107
}
@@ -124,21 +124,21 @@ public function migrate(): void {
124
124
$ this ->generator ->modifyField ($ updatedField ['table ' ],$ updatedField ['name ' ],$ updatedField ['attributes ' ]);
125
125
}
126
126
$ missingPks =$ checker ->checkPrimaryKeys ($ model );
127
- if (! \empty ($ missingPks )) {
127
+ if (\count ($ missingPks )> 0 ) {
128
128
$ pks =$ missingPks ['primaryKeys ' ];
129
129
$ tablereversor ->addPrimaryKeys ($ this ->generator ,$ pks );
130
130
}
131
131
$ missingFks =$ checker ->checkManyToOne ($ model );
132
- if (! \empty ($ missingFks )){
132
+ if ( \count ($ missingFks )> 0 ){
133
133
foreach ($ missingFks as $ fk ){
134
134
$ this ->generator ->addForeignKey ($ fk ['table ' ], $ fk ['column ' ], $ fk ['fkTable ' ], $ fk ['fkId ' ]);
135
135
}
136
136
}
137
137
138
138
$ missingFks =$ checker ->checkManyToMany ($ model );
139
- if (! \empty ($ missingFks )){
139
+ if ( \count ($ missingFks )> 0 ){
140
140
foreach ($ missingFks as $ fk ){
141
- if (!$ this ->generator ->hasToCreateTable ($ fk ['table ' ])) {
141
+ if (!$ this ->generator ->hasToCreateTable ($ fk ['table ' ])) {
142
142
$ this ->checkManyToManyFields ($ checker , $ fk ['table ' ], $ fk ['column ' ],$ newMissingPks );
143
143
$ this ->generator ->addForeignKey ($ fk ['table ' ], $ fk ['column ' ], $ fk ['fkTable ' ], $ fk ['fkId ' ]);
144
144
}
@@ -156,7 +156,7 @@ private function checkManyToManyFields(DatabaseChecker $checker,string $table,st
156
156
if (!isset ($ originalFieldInfos [$ field ])) {
157
157
$ this ->generator ->addField ($ table , $ field , ['type ' => 'int ' ]);
158
158
}
159
- if (! in_array ($ field , $ pks )){
159
+ if (\array_search ($ field ,$ pks )=== false ){
160
160
$ newMissingPks [$ table ][]=$ field ;
161
161
}
162
162
}
0 commit comments