Skip to content

Commit dbca8f3

Browse files
fix: missing migrations table when installing auth
1 parent 1af376a commit dbca8f3

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

packages/database/src/Migrations/MigrationManager.php

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

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

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

0 commit comments

Comments
 (0)