Skip to content

Commit 35bef08

Browse files
fix: missing migrations table when installing auth
1 parent 16655b4 commit 35bef08

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

packages/database/src/Migrations/MigrationManager.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ public function validate(): void
188188

189189
public function executeUp(MigratesUp $migration): void
190190
{
191+
if (! $migration instanceof CreateMigrationsTable) {
192+
$this->ensureMigrationsTableExists();
193+
}
194+
191195
if ($migration instanceof ShouldMigrate && $migration->shouldMigrate($this->database) === false) {
192196
return;
193197
}
@@ -334,4 +338,20 @@ private function getMinifiedSqlFromStatement(?QueryStatement $statement): string
334338

335339
return $sql;
336340
}
341+
342+
private function ensureMigrationsTableExists(): void
343+
{
344+
try {
345+
Migration::select()
346+
->onDatabase($this->onDatabase)
347+
->limit(1)
348+
->all();
349+
} catch (QueryWasInvalid $exception) {
350+
if ($this->dialect->isTableNotFoundError($exception)) {
351+
$this->executeUp(new CreateMigrationsTable());
352+
} else {
353+
throw $exception;
354+
}
355+
}
356+
}
337357
}

0 commit comments

Comments
 (0)