Skip to content

Commit

Permalink
Compensate difference between DBAL schema introspection and ORM gener…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
morozov committed Oct 10, 2024
1 parent 03b040e commit 2bc98c4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Generator/DiffGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Check warning on line 75 in src/Generator/DiffGenerator.php

View check run for this annotation

Codecov / codecov/patch

src/Generator/DiffGenerator.php#L73-L75

Added lines #L73 - L75 were not covered by tests
}
}

$comparator = $this->schemaManager->createComparator();

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

0 comments on commit 2bc98c4

Please sign in to comment.