@@ -169,7 +169,13 @@ protected function buildFlatXMLDataSet(array $dataSet): string
169169
170170 protected function createDatabase (): void
171171 {
172- $ this ->runMigrate ('down ' , ['all ' ]);
172+ $ command = $ this ->getDb ()->createCommand ();
173+
174+ if ($ this ->getDb ()->getTableSchema ('migration ' , true ) !== null ) {
175+ $ command ->dropTable ('migration ' )->execute ();
176+ }
177+
178+ $ this ->runMigrate ('down ' , ['all ' => true ]);
173179 $ this ->runMigrate ('up ' );
174180 }
175181
@@ -298,30 +304,6 @@ protected function getDataSetMultipleTree(): array
298304 return array_values ($ dataSetMultipleTree );
299305 }
300306
301- /**
302- * @phpstan-param array<string, mixed> $params
303- */
304- protected function runMigrate (string $ action , array $ params = []): mixed
305- {
306- $ migrate = new EchoMigrateController (
307- 'migrate ' ,
308- Yii::$ app ,
309- [
310- 'migrationPath ' => dirname (__DIR__ ) . '/migrations ' ,
311- 'interactive ' => false ,
312- ],
313- );
314-
315- ob_start ();
316- ob_implicit_flush (false );
317-
318- $ result = $ migrate ->run ($ action , $ params );
319-
320- ob_get_clean ();
321-
322- return $ result ;
323- }
324-
325307 protected function loadFixtureXML (string $ fileName ): SimpleXMLElement
326308 {
327309 $ filePath = "{$ this ->fixtureDirectory }/ {$ fileName }" ;
@@ -393,6 +375,30 @@ protected function replaceQuotes(string $sql): string
393375 };
394376 }
395377
378+ /**
379+ * @phpstan-param array<string, mixed> $params
380+ */
381+ protected function runMigrate (string $ action , array $ params = []): mixed
382+ {
383+ $ migrate = new EchoMigrateController (
384+ 'migrate ' ,
385+ Yii::$ app ,
386+ [
387+ 'migrationPath ' => dirname (__DIR__ ) . '/migrations ' ,
388+ 'interactive ' => false ,
389+ ],
390+ );
391+
392+ ob_start ();
393+ ob_implicit_flush (false );
394+
395+ $ result = $ migrate ->run ($ action , $ params );
396+
397+ ob_get_clean ();
398+
399+ return $ result ;
400+ }
401+
396402 /**
397403 * Applies database updates to tree nodes.
398404 *
0 commit comments