forked from doctrine/dbal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix incorrect syntax for dropping primary indexes in PostgreSQL (doct…
…rine#6025) | Q | A |------------- | ----------- | Type | bug/feature/improvement | Fixed issues | doctrine#6024 #### Summary The correct way of dropping primary index in PostgreSQL is not dropping the index, but removing the primary key constraints --------- Co-authored-by: Alexander M. Turek <me@derrabus.de>
- Loading branch information
1 parent
4de9c19
commit 19f0dec
Showing
3 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Doctrine\DBAL\Tests\Functional\Driver; | ||
|
||
use Doctrine\DBAL\Schema\Table; | ||
use Doctrine\DBAL\Tests\FunctionalTestCase; | ||
use Doctrine\DBAL\Tests\TestUtil; | ||
|
||
class DBAL6024Test extends FunctionalTestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
if (TestUtil::isDriverOneOf('pdo_pgsql', 'pgsql')) { | ||
return; | ||
} | ||
|
||
self::markTestSkipped('This test requires the pdo_pgsql or the pgsql driver.'); | ||
} | ||
|
||
public function testDropPrimaryKey(): void | ||
{ | ||
$table = new Table('mytable'); | ||
$table->addColumn('id', 'integer'); | ||
$table->setPrimaryKey(['id']); | ||
$this->dropAndCreateTable($table); | ||
|
||
$newTable = clone $table; | ||
$newTable->dropPrimaryKey(); | ||
|
||
$schemaManager = $this->connection->createSchemaManager(); | ||
$diff = $schemaManager->createComparator()->compareTables($table, $newTable); | ||
|
||
$statements = $this->connection->getDatabasePlatform()->getAlterTableSQL($diff); | ||
foreach ($statements as $statement) { | ||
$this->connection->executeStatement($statement); | ||
} | ||
|
||
$validationSchema = $schemaManager->introspectSchema(); | ||
$validationTable = $validationSchema->getTable($table->getName()); | ||
|
||
$this->assertNull($validationTable->getPrimaryKey()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters