Skip to content

Commit 5007eb1

Browse files
authored
Merge pull request #1463 from morozov/issues/1415
Compensate difference between DBAL schema introspection and ORM generation
2 parents 03b040e + 2bc98c4 commit 5007eb1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Generator/DiffGenerator.php

+13
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Doctrine\Migrations\Generator\Exception\NoChangesDetected;
1313
use Doctrine\Migrations\Provider\SchemaProvider;
1414

15+
use function method_exists;
1516
use function preg_match;
1617
use function strpos;
1718
use function substr;
@@ -63,6 +64,18 @@ static function ($assetName) use ($filterExpression) {
6364

6465
$toSchema = $this->createToSchema();
6566

67+
// prior to DBAL 4.0, the schema name was set to the first element in the search path,
68+
// which is not necessarily the default schema name
69+
if (
70+
! method_exists($this->schemaManager, 'getSchemaSearchPaths')
71+
&& $this->platform->supportsSchemas()
72+
) {
73+
$defaultNamespace = $toSchema->getName();
74+
if ($defaultNamespace !== '') {
75+
$toSchema->createNamespace($defaultNamespace);
76+
}
77+
}
78+
6679
$comparator = $this->schemaManager->createComparator();
6780

6881
$upSql = $this->platform->getAlterSchemaSQL($comparator->compareSchemas($fromSchema, $toSchema));

0 commit comments

Comments
 (0)