From 8141cc5bc30cfb619a473c36bba45999b970612b Mon Sep 17 00:00:00 2001 From: mscherer Date: Tue, 27 Jan 2026 09:51:55 +0100 Subject: [PATCH] Fix dump command error when migrations directory does not exist When running migrations on a plugin without a migrations directory, the DumpCommand would fail with a file_put_contents error. Now it gracefully skips the dump with a verbose message instead. Fixes #1008 --- src/Command/DumpCommand.php | 6 ++++++ tests/TestCase/Command/DumpCommandTest.php | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/Command/DumpCommand.php b/src/Command/DumpCommand.php index 53c79026e..ff779e598 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 45c07b040..cb3f54664 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']);