diff --git a/src/Command/DumpCommand.php b/src/Command/DumpCommand.php index 53c79026..ff779e59 100644 --- a/src/Command/DumpCommand.php +++ b/src/Command/DumpCommand.php @@ -112,6 +112,12 @@ public function execute(Arguments $args, ConsoleIo $io): ?int ]); $config = $factory->createConfig(); $path = $config->getMigrationPath(); + + if (!is_dir($path)) { + $io->verbose('No migrations directory found, skipping dump.'); + + return self::CODE_SUCCESS; + } $connectionName = (string)$config->getConnection(); $connection = ConnectionManager::get($connectionName); assert($connection instanceof Connection); diff --git a/tests/TestCase/Command/DumpCommandTest.php b/tests/TestCase/Command/DumpCommandTest.php index 45c07b04..cb3f5466 100644 --- a/tests/TestCase/Command/DumpCommandTest.php +++ b/tests/TestCase/Command/DumpCommandTest.php @@ -84,6 +84,13 @@ public function testExecuteSuccess(): void $this->assertEquals(['id', 'letter'], $generatedDump['letters']->columns()); } + public function testExecuteNoMigrationsDirectory(): void + { + $this->exec('migrations dump --connection test --source NonExistentMigrations'); + + $this->assertExitSuccess(); + } + public function testExecutePlugin(): void { $this->loadPlugins(['Migrator']);