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));