Skip to content

Commit 7a42619

Browse files
committed
Add more tests for different PKs
1 parent cc82918 commit 7a42619

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

src/lib/generators/MigrationsGenerator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ public function buildMigrations():array
131131
}
132132
}
133133

134+
// TODO remove
134135
// for deleted schema, create migration for drop table
135136
// foreach ($this->tablesToDrop as $tableName) {
136137
// $table = Yii::$app->db->schema->getTableSchema($tableName);

tests/specs/issue_fix/132_create_migration_for_drop_table/132_create_migration_for_drop_table.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ x-deleted-schemas: # don't use x-keep-table, use x-deleted-schemas
77
- Pristine
88
- Fruit # table name evaluated to `itt_fruits`. `itt_` is prefix
99
# - Mango: the_mango7 # custom table name; `x-table`
10-
# - Upk
10+
- Upk
11+
- Bigpk
12+
- Ubigpk
1113

1214
paths:
1315
/:

tests/unit/IssueFixTest.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,18 +283,27 @@ public function testCreateMigrationForDropTable132()
283283
// $this->deleteTablesForCreateMigrationForDropTable132();
284284
$this->createTablesForCreateMigrationForDropTable132();
285285
$this->runGenerator($testFile);
286-
$this->runActualMigrations('mysql', 3);
286+
$this->runActualMigrations('mysql', 6);
287287
// ... TODO compare files
288288
$this->deleteTablesForCreateMigrationForDropTable132();
289-
// $this->deleteTables();
289+
$this->deleteTables();
290290
}
291291

292292
private function createTablesForCreateMigrationForDropTable132()
293293
{
294-
// Yii::$app->db->createCommand()->createTable('{{%upks}}', [
295-
// 'id' => 'upk',
296-
// 'name' => 'string(150)',
297-
// ])->execute();
294+
Yii::$app->db->createCommand()->createTable('{{%upks}}', [
295+
'id' => 'upk',
296+
'name' => 'string(150)',
297+
])->execute();
298+
Yii::$app->db->createCommand()->createTable('{{%bigpks}}', [
299+
'id' => 'bigpk',
300+
'name' => 'string(150)',
301+
])->execute();
302+
Yii::$app->db->createCommand()->createTable('{{%ubigpks}}', [
303+
'id' => 'ubigpk',
304+
'name' => 'string(150)',
305+
])->execute();
306+
298307

299308
Yii::$app->db->createCommand()->createTable('{{%fruits}}', [
300309
'id' => 'pk',
@@ -314,6 +323,8 @@ private function deleteTablesForCreateMigrationForDropTable132()
314323
Yii::$app->db->createCommand('DROP TABLE IF EXISTS {{%pristines}}')->execute();
315324
Yii::$app->db->createCommand('DROP TABLE IF EXISTS {{%fruits}}')->execute();
316325
Yii::$app->db->createCommand('DROP TABLE IF EXISTS {{%upks}}')->execute();
326+
Yii::$app->db->createCommand('DROP TABLE IF EXISTS {{%bigpks}}')->execute();
327+
Yii::$app->db->createCommand('DROP TABLE IF EXISTS {{%ubigpks}}')->execute();
317328
}
318329

319330
public function test162BugDollarrefWithXFaker()

0 commit comments

Comments
 (0)