8000 use Table::addPrimaryKeyConstraint() with Doctrine DBAL 4.3+ · symfony/doctrine-messenger@c353e6e · GitHub
[go: up one dir, main page]

Skip to content

Commit c353e6e

Browse files
committed
use Table::addPrimaryKeyConstraint() with Doctrine DBAL 4.3+
1 parent 55cd0f7 commit c353e6e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Transport/Connection.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
use Doctrine\DBAL\Query\QueryBuilder;
2424
use Doctrine\DBAL\Result;
2525
use Doctrine\DBAL\Schema\AbstractAsset;
26+
use Doctrine\DBAL\Schema\Name\Identifier;
27+
use Doctrine\DBAL\Schema\Name\UnqualifiedName;
28+
use Doctrine\DBAL\Schema\PrimaryKeyConstraint;
2629
use Doctrine\DBAL\Schema\Schema;
2730
use Doctrine\DBAL\Schema\Table;
2831
use Doctrine\DBAL\Types\Types;
@@ -519,7 +522,11 @@ private function addTableToSchema(Schema $schema): void
519522
->setNotnull(true);
520523
$table->addColumn('delivered_at', Types::DATETIME_IMMUTABLE)
521524
->setNotnull(false);
522-
$table->setPrimaryKey(['id']);
525+
if (class_exists(PrimaryKeyConstraint::class)) {
526+
$table->addPrimaryKeyConstraint(new PrimaryKeyConstraint(null, [new UnqualifiedName(Identifier::unquoted('id'))], true));
527+
} else {
528+
$table->setPrimaryKey(['id']);
529+
}
523530
$table->addIndex(['queue_name']);
524531
$table->addIndex(['available_at']);
525532
$table->addIndex(['delivered_at']);

0 commit comments

Comments
 (0)
0