File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
packages/database/src/Migrations Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments