@@ -283,7 +283,7 @@ public function testCreateMigrationForDropTable132()
283
283
// $this->deleteTablesForCreateMigrationForDropTable132();
284
284
$ this ->createTablesForCreateMigrationForDropTable132 ();
285
285
$ this ->runGenerator ($ testFile );
286
- $ this ->runActualMigrations ('mysql ' , 6 );
286
+ $ this ->runActualMigrations ('mysql ' , 8 );
287
287
// ... TODO compare files
288
288
$ this ->deleteTablesForCreateMigrationForDropTable132 ();
289
289
$ this ->deleteTables ();
@@ -304,27 +304,47 @@ private function createTablesForCreateMigrationForDropTable132()
304
304
'name ' => 'string(150) ' ,
305
305
])->execute ();
306
306
307
-
307
+ // ---
308
308
Yii::$ app ->db ->createCommand ()->createTable ('{{%fruits}} ' , [
309
309
'id ' => 'pk ' ,
310
310
'name ' => 'string(150) ' ,
311
+ 'food_of ' => 'int '
311
312
])->execute ();
312
313
Yii::$ app ->db ->createCommand ()->createTable ('{{%pristines}} ' , [
313
314
'id ' => 'pk ' ,
314
315
'name ' => 'string(151) ' ,
315
316
'fruit_id ' => 'int ' , // FK
316
317
])->execute ();
317
318
Yii::$ app ->db ->createCommand ()->addForeignKey ('name ' , '{{%pristines}} ' , 'fruit_id ' , '{{%fruits}} ' , 'id ' )->execute ();
319
+
320
+ // ---
321
+ Yii::$ app ->db ->createCommand ()->createTable ('{{%the_animal_table_name}} ' , [
322
+ 'id ' => 'pk ' ,
323
+ 'name ' => 'string(150) ' ,
324
+ ])->execute ();
325
+ Yii::$ app ->db ->createCommand ()->addForeignKey ('name2 ' , '{{%fruits}} ' , 'food_of ' , '{{%the_animal_table_name}} ' , 'id ' )->execute ();
326
+ Yii::$ app ->db ->createCommand ()->createTable ('{{%the_mango_table_name}} ' , [
327
+ 'id ' => 'pk ' ,
328
+ 'name ' => 'string(150) ' ,
329
+ 'food_of ' => 'int '
330
+ ])->execute ();
331
+ Yii::$ app ->db ->createCommand ()->addForeignKey ('animal_fruit_fk ' , '{{%the_mango_table_name}} ' , 'food_of ' , '{{%the_animal_table_name}} ' , 'id ' )->execute ();
318
332
}
319
333
320
334
private function deleteTablesForCreateMigrationForDropTable132 ()
321
335
{
322
336
Yii::$ app ->db ->createCommand ()->dropForeignKey ('name ' , '{{%pristines}} ' )->execute ();
323
337
Yii::$ app ->db ->createCommand ('DROP TABLE IF EXISTS {{%pristines}} ' )->execute ();
338
+ Yii::$ app ->db ->createCommand ()->dropForeignKey ('name2 ' , '{{%fruits}} ' )->execute ();
324
339
Yii::$ app ->db ->createCommand ('DROP TABLE IF EXISTS {{%fruits}} ' )->execute ();
340
+
325
341
Yii::$ app ->db ->createCommand ('DROP TABLE IF EXISTS {{%upks}} ' )->execute ();
326
342
Yii::$ app ->db ->createCommand ('DROP TABLE IF EXISTS {{%bigpks}} ' )->execute ();
327
343
Yii::$ app ->db ->createCommand ('DROP TABLE IF EXISTS {{%ubigpks}} ' )->execute ();
344
+
345
+ Yii::$ app ->db ->createCommand ()->dropForeignKey ('animal_fruit_fk ' , '{{%the_mango_table_name}} ' )->execute ();
346
+ Yii::$ app ->db ->createCommand ('DROP TABLE IF EXISTS {{%the_mango_table_name}} ' )->execute ();
347
+ Yii::$ app ->db ->createCommand ('DROP TABLE IF EXISTS {{%the_animal_table_name}} ' )->execute ();
328
348
}
329
349
330
350
public function test162BugDollarrefWithXFaker ()
0 commit comments