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