-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for unlogged tables in PostgreSQL (#6046)
| Q | A |------------- | ----------- | Type | bug/feature/improvement | Feature | see #6044 #### Summary Add support for creating unlogged PostgreSQL tables: https://www.postgresql.org/docs/current/sql-createtable.html I added a boolean `unlogged` option to `default_table_options` doctrine configuration https://www.doctrine-project.org/projects/doctrine-bundle/en/latest/configuration.html For example: ```yaml doctrine: dbal: default_table_options: unlogged: true ``` --------- Co-authored-by: Alexander M. Turek <me@derrabus.de>
- Loading branch information
1 parent
01c4ce1
commit f97f825
Showing
4 changed files
with
68 additions
and
1 deletion.
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
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,52 @@ | ||
<?php | ||
|
||
namespace Doctrine\DBAL\Tests\Functional\Driver; | ||
|
||
use Doctrine\DBAL\Schema\Table; | ||
use Doctrine\DBAL\Tests\FunctionalTestCase; | ||
use Doctrine\DBAL\Tests\TestUtil; | ||
|
||
class DBAL6044Test extends FunctionalTestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
if (TestUtil::isDriverOneOf('pdo_pgsql', 'pgsql')) { | ||
return; | ||
} | ||
|
||
self::markTestSkipped('This test requires the pdo_pgsql or the pgsql driver.'); | ||
} | ||
|
||
public function testUnloggedTables(): void | ||
{ | ||
$unloggedTable = new Table('my_unlogged'); | ||
$unloggedTable->addOption('unlogged', true); | ||
$unloggedTable->addColumn('foo', 'string'); | ||
$this->dropAndCreateTable($unloggedTable); | ||
|
||
$loggedTable = new Table('my_logged'); | ||
$loggedTable->addColumn('foo', 'string'); | ||
$this->dropAndCreateTable($loggedTable); | ||
|
||
$schemaManager = $this->connection->createSchemaManager(); | ||
|
||
$validationSchema = $schemaManager->introspectSchema(); | ||
$validationUnloggedTable = $validationSchema->getTable($unloggedTable->getName()); | ||
$this->assertTrue($validationUnloggedTable->getOption('unlogged')); | ||
$validationLoggedTable = $validationSchema->getTable($loggedTable->getName()); | ||
$this->assertFalse($validationLoggedTable->getOption('unlogged')); | ||
|
||
$sql = 'SELECT relpersistence FROM pg_class WHERE relname = ?'; | ||
$stmt = $this->connection->prepare($sql); | ||
|
||
$stmt->bindValue(1, $unloggedTable->getName()); | ||
$unloggedTablePersistenceType = $stmt->executeQuery()->fetchOne(); | ||
$this->assertEquals('u', $unloggedTablePersistenceType); | ||
|
||
$stmt->bindValue(1, $loggedTable->getName()); | ||
$loggedTablePersistenceType = $stmt->executeQuery()->fetchOne(); | ||
$this->assertEquals('p', $loggedTablePersistenceType); | ||
} | ||
} |
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