Skip to content

Commit ed6f85c

Browse files
authored
fix(database): improved check on missing migrations table (#1092)
1 parent 90fa20c commit ed6f85c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Tempest/Database/src/Migrations/MigrationManager.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,13 @@ public function up(): void
3434
{
3535
try {
3636
$existingMigrations = Migration::all();
37-
} catch (PDOException) {
38-
$this->executeUp(new CreateMigrationsTable());
39-
40-
$existingMigrations = Migration::all();
37+
} catch (PDOException $pdoException) {
38+
if ($pdoException->getCode() === $this->databaseConfig->dialect->tableNotFoundCode() && str_contains($pdoException->getMessage(), 'table')) {
39+
$this->executeUp(new CreateMigrationsTable());
40+
$existingMigrations = Migration::all();
41+
} else {
42+
throw $pdoException;
43+
}
4144
}
4245

4346
$existingMigrations = array_map(

0 commit comments

Comments
 (0)