44
55namespace Tempest \Database \Migrations ;
66
7- use PDOException ;
87use Tempest \Container \Container ;
98use Tempest \Database \Builder \ModelDefinition ;
109use Tempest \Database \Config \DatabaseDialect ;
@@ -48,12 +47,12 @@ public function up(): void
4847 {
4948 try {
5049 $ existingMigrations = Migration::select ()->onDatabase ($ this ->onDatabase )->all ();
51- } catch (PDOException $ pdoException ) {
52- if ($ this ->dialect ->isTableNotFoundError ($ pdoException )) {
50+ } catch (QueryWasInvalid $ queryWasInvalid ) {
51+ if ($ this ->dialect ->isTableNotFoundError ($ queryWasInvalid )) {
5352 $ this ->executeUp (new CreateMigrationsTable ());
5453 $ existingMigrations = Migration::select ()->onDatabase ($ this ->onDatabase )->all ();
5554 } else {
56- throw $ pdoException ;
55+ throw $ queryWasInvalid ;
5756 }
5857 }
5958
@@ -75,9 +74,9 @@ public function down(): void
7574 {
7675 try {
7776 $ existingMigrations = Migration::select ()->onDatabase ($ this ->onDatabase )->all ();
78- } catch (PDOException $ pdoException ) {
79- if (! $ this ->dialect ->isTableNotFoundError ($ pdoException )) {
80- throw $ pdoException ;
77+ } catch (QueryWasInvalid $ queryWasInvalid ) {
78+ if (! $ this ->dialect ->isTableNotFoundError ($ queryWasInvalid )) {
79+ throw $ queryWasInvalid ;
8180 }
8281
8382 event (new MigrationFailed (
@@ -132,7 +131,7 @@ public function rehashAll(): void
132131 $ existingMigrations = Migration::select ()
133132 ->onDatabase ($ this ->onDatabase )
134133 ->all ();
135- } catch (PDOException ) {
134+ } catch (QueryWasInvalid ) {
136135 return ;
137136 }
138137
@@ -163,7 +162,7 @@ public function validate(): void
163162 {
164163 try {
165164 $ existingMigrations = Migration::select ()->onDatabase ($ this ->onDatabase )->all ();
166- } catch (PDOException ) {
165+ } catch (QueryWasInvalid ) {
167166 return ;
168167 }
169168
@@ -231,10 +230,10 @@ public function executeUp(MigrationInterface $migration): void
231230 hash: $ this ->getMigrationHash ($ migration ),
232231 ),
233232 );
234- } catch (PDOException $ pdoException ) {
235- event (new MigrationFailed ($ migration ->name , $ pdoException ));
233+ } catch (QueryWasInvalid $ queryWasInvalid ) {
234+ event (new MigrationFailed ($ migration ->name , $ queryWasInvalid ));
236235
237- throw $ pdoException ;
236+ throw $ queryWasInvalid ;
238237 }
239238
240239 event (new MigrationMigrated ($ migration ->name ));
@@ -264,13 +263,13 @@ public function executeDown(MigrationInterface $migration): void
264263
265264 // Disable foreign key checks
266265 new SetForeignKeyChecksStatement (enable: true )->execute ($ this ->dialect , $ this ->onDatabase );
267- } catch (PDOException $ pdoException ) {
266+ } catch (QueryWasInvalid $ queryWasInvalid ) {
268267 // Disable foreign key checks
269268 new SetForeignKeyChecksStatement (enable: true )->execute ($ this ->dialect , $ this ->onDatabase );
270269
271- event (new MigrationFailed ($ migration ->name , $ pdoException ));
270+ event (new MigrationFailed ($ migration ->name , $ queryWasInvalid ));
272271
273- throw $ pdoException ;
272+ throw $ queryWasInvalid ;
274273 }
275274
276275 try {
0 commit comments