8000 bug #40055 [Messenger] Fix Doctrine setup when using a migration (fab… · symfony/symfony@8f325f5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8f325f5

Browse files
committed
bug #40055 [Messenger] Fix Doctrine setup when using a migration (fabpot)
This PR was merged into the 5.2 branch. Discussion ---------- [Messenger] Fix Doctrine setup when using a migration | Q | A | ------------- | --- | Branch? | 5.2 <!-- see below --> | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Fix #39928 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT | Doc PR | n/a #38136 fixed running `messenger:setup-transports` (issue reported in #37179), but it breaks usage with `make:migration` (reported in #39928) as code is already executed in a transaction. This PR fixes both use cases. Commits ------- 42eeb44 [Messenger] Fix Doctrine setup when using a migration
2 parents a07638b + 42eeb44 commit 8f325f5

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/PostgreSqlConnection.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function setup(): void
8787
{
8888
parent::setup();
8989

90-
$this->executeStatement(implode("\n", $this->getTriggerSql()));
90+
$this->executeStatement('BEGIN;'.implode("\n", $this->getTriggerSql()).'COMMIT;');
9191
}
9292

9393
/**
@@ -109,7 +109,6 @@ public function getExtraSetupSqlForTable(Table $createdTable): array
109109
private function getTriggerSql(): array
110110
{
111111
return [
112-
'BEGIN;',
113112
sprintf('LOCK TABLE %s;', $this->configuration['table_name']),
114113
// create trigger function
115114
sprintf(<<<'SQL'
@@ -124,7 +123,6 @@ private function getTriggerSql(): array
124123
// register trigger
125124
sprintf('DROP TRIGGER IF EXISTS notify_trigger ON %s;', $this->configuration['table_name']),
126125
sprintf('CREATE TRIGGER notify_trigger AFTER INSERT OR UPDATE ON %1$s FOR EACH ROW EXECUTE PROCEDURE notify_%1$s();', $this->configuration['table_name']),
127-
'COMMIT;',
128126
];
129127
}
130128

0 commit comments

Comments
 (0)
0