Skip to content

Commit 7c52f34

Browse files
authored
test: guides migration table exist (#6931)
1 parent 64c6e10 commit 7c52f34

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

docs/src/Kernel.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,15 @@ public function executeMigrations(string $direction = Direction::UP): void
164164
$em = $this->getContainer()->get('doctrine.orm.entity_manager');
165165
$loader = new ExistingEntityManager($em);
166166
$dependencyFactory = DependencyFactory::fromEntityManager($confLoader, $loader);
167+
$metadataStorage = $dependencyFactory->getMetadataStorage();
167168

168-
$dependencyFactory->getMetadataStorage()->ensureInitialized();
169-
$executed = $dependencyFactory->getMetadataStorage()->getExecutedMigrations();
169+
try {
170+
$metadataStorage->ensureInitialized();
171+
} catch (\Exception) {
172+
// table exists
173+
}
174+
175+
$executed = $metadataStorage->getExecutedMigrations();
170176

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

0 commit comments

Comments
 (0)