From 2bc98c40cb5deac5e7595e662e04ab6730d247fb Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Thu, 10 Oct 2024 22:11:13 +0200 Subject: [PATCH] Compensate difference between DBAL schema introspection and ORM generation --- src/Generator/DiffGenerator.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Generator/DiffGenerator.php b/src/Generator/DiffGenerator.php index 19b6f3da8..240885ab5 100644 --- a/src/Generator/DiffGenerator.php +++ b/src/Generator/DiffGenerator.php @@ -12,6 +12,7 @@ use Doctrine\Migrations\Generator\Exception\NoChangesDetected; use Doctrine\Migrations\Provider\SchemaProvider; +use function method_exists; use function preg_match; use function strpos; use function substr; @@ -63,6 +64,18 @@ static function ($assetName) use ($filterExpression) { $toSchema = $this->createToSchema(); + // prior to DBAL 4.0, the schema name was set to the first element in the search path, + // which is not necessarily the default schema name + if ( + ! method_exists($this->schemaManager, 'getSchemaSearchPaths') + && $this->platform->supportsSchemas() + ) { + $defaultNamespace = $toSchema->getName(); + if ($defaultNamespace !== '') { + $toSchema->createNamespace($defaultNamespace); + } + } + $comparator = $this->schemaManager->createComparator(); $upSql = $this->platform->getAlterSchemaSQL($comparator->compareSchemas($fromSchema, $toSchema));