Skip to content

Commit

Permalink
Merge pull request #10116 from greg0ire/address-dbal-deprecations
Browse files Browse the repository at this point in the history
Address deprecations form DBAL
  • Loading branch information
greg0ire committed Oct 10, 2022
2 parents 0e65b0c + 8e06295 commit 7ce9a6f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
5 changes: 3 additions & 2 deletions lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php
Expand Up @@ -304,14 +304,15 @@ private function reverseEngineerMappingFromDatabase(): void
$allForeignKeyColumns = array_merge($allForeignKeyColumns, $foreignKey->getLocalColumns());
}

if (! $table->hasPrimaryKey()) {
$primaryKey = $table->getPrimaryKey();
if ($primaryKey === null) {
throw new MappingException(
'Table ' . $tableName . ' has no primary key. Doctrine does not ' .
"support reverse engineering from tables that don't have a primary key."
);
}

$pkColumns = $table->getPrimaryKey()->getColumns();
$pkColumns = $primaryKey->getColumns();

sort($pkColumns);
sort($allForeignKeyColumns);
Expand Down
17 changes: 10 additions & 7 deletions lib/Doctrine/ORM/Tools/SchemaTool.php
Expand Up @@ -893,13 +893,16 @@ public function getDropSchemaSQL(array $classes)
}

foreach ($schema->getTables() as $table) {
if ($table->hasPrimaryKey()) {
$columns = $table->getPrimaryKey()->getColumns();
if (count($columns) === 1) {
$checkSequence = $table->getName() . '_' . $columns[0] . '_seq';
if ($deployedSchema->hasSequence($checkSequence) && ! $schema->hasSequence($checkSequence)) {
$schema->createSequence($checkSequence);
}
$primaryKey = $table->getPrimaryKey();
if ($primaryKey === null) {
continue;
}

$columns = $primaryKey->getColumns();
if (count($columns) === 1) {
$checkSequence = $table->getName() . '_' . $columns[0] . '_seq';
if ($deployedSchema->hasSequence($checkSequence) && ! $schema->hasSequence($checkSequence)) {
$schema->createSequence($checkSequence);
}
}
}
Expand Down

0 comments on commit 7ce9a6f

Please sign in to comment.