Skip to content

Commit 6a3ddf2

Browse files
driesvintstaylorotwell
andauthoredJul 1, 2021
[8.x] Improve pretend run Doctrine failure message (#37879)
* Improve pretend run Doctrine failure message * Update Migrator.php Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 7bfc087 commit 6a3ddf2

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed
 

‎src/Illuminate/Database/Migrations/Migrator.php

+13-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Illuminate\Database\Migrations;
44

5+
use Doctrine\DBAL\Schema\SchemaException;
56
use Illuminate\Contracts\Events\Dispatcher;
67
use Illuminate\Database\ConnectionResolverInterface as Resolver;
78
use Illuminate\Database\Events\MigrationEnded;
@@ -411,16 +412,22 @@ protected function runMigration($migration, $method)
411412
*/
412413
protected function pretendToRun($migration, $method)
413414
{
414-
foreach ($this->getQueries($migration, $method) as $query) {
415-
$name = get_class($migration);
415+
try {
416+
foreach ($this->getQueries($migration, $method) as $query) {
417+
$name = get_class($migration);
418+
419+
$reflectionClass = new ReflectionClass($migration);
416420

417-
$reflectionClass = new ReflectionClass($migration);
421+
if ($reflectionClass->isAnonymous()) {
422+
$name = $this->getMigrationName($reflectionClass->getFileName());
423+
}
418424

419-
if ($reflectionClass->isAnonymous()) {
420-
$name = $this->getMigrationName($reflectionClass->getFileName());
425+
$this->note("<info>{$name}:</info> {$query['query']}");
421426
}
427+
} catch (SchemaException $e) {
428+
$name = get_class($migration);
422429

423-
$this->note("<info>{$name}:</info> {$query['query']}");
430+
$this->note("<info>{$name}:</info> failed to dump queries. This may be due to changing database columns using Doctrine, which is not supported while pretending to run migrations.");
424431
}
425432
}
426433

0 commit comments

Comments
 (0)