Skip to content

Commit

Permalink
test: guides migration table exist (#6931)
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka authored Jan 28, 2025
1 parent 64c6e10 commit 7c52f34
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions docs/src/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,15 @@ public function executeMigrations(string $direction = Direction::UP): void
$em = $this->getContainer()->get('doctrine.orm.entity_manager');
$loader = new ExistingEntityManager($em);
$dependencyFactory = DependencyFactory::fromEntityManager($confLoader, $loader);
$metadataStorage = $dependencyFactory->getMetadataStorage();

$dependencyFactory->getMetadataStorage()->ensureInitialized();
$executed = $dependencyFactory->getMetadataStorage()->getExecutedMigrations();
try {
$metadataStorage->ensureInitialized();
} catch (\Exception) {
// table exists
}

$executed = $metadataStorage->getExecutedMigrations();

if ($executed->hasMigration(new Version($migrationClass)) && Direction::DOWN !== $direction) {
continue;
Expand Down

0 comments on commit 7c52f34

Please sign in to comment.