Skip to content

Commit

Permalink
Fix primary key handling on postgres
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Jul 27, 2018
1 parent 008c8dd commit ef5074a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/private/DB/MigrationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,12 +503,13 @@ public function ensureOracleIdentifierLengthLimit(Schema $schema, int $prefixLen
$isUsingDefaultName = $indexName === 'primary';

if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) {
$defaultName = $table->getName() . '_' . implode('_', $primaryKey->getColumns()) . '_seq';
$defaultName = $table->getName() . '_pkey';
$isUsingDefaultName = strtolower($defaultName) === $indexName;

if ($isUsingDefaultName) {
$sequences = array_filter($sequences, function(Sequence $sequence) use ($indexName) {
return $sequence->getName() !== $indexName;
$sequenceName = $table->getName() . '_' . implode('_', $primaryKey->getColumns()) . '_seq';
$sequences = array_filter($sequences, function(Sequence $sequence) use ($sequenceName) {
return $sequence->getName() !== $sequenceName;
});
}
} else if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) {
Expand Down

0 comments on commit ef5074a

Please sign in to comment.