Run postgres setup trigger in transaction

This commit is contained in:
Arkadiusz Kondas 2020-09-10 10:05:16 +02:00
parent 3c5a4ed06e
commit 7ed93b4dc0
No known key found for this signature in database
GPG Key ID: 0DCDDE5537384C29

View File

@ -109,6 +109,7 @@ final class PostgreSqlConnection extends Connection
private function getTriggerSql(): array
{
return [
'BEGIN;',
sprintf('LOCK TABLE %s;', $this->configuration['table_name']),
// create trigger function
sprintf(<<<'SQL'
@ -123,6 +124,7 @@ SQL
// register trigger
sprintf('DROP TRIGGER IF EXISTS notify_trigger ON %s;', $this->configuration['table_name']),
sprintf('CREATE TRIGGER notify_trigger AFTER INSERT ON %1$s FOR EACH ROW EXECUTE PROCEDURE notify_%1$s();', $this->configuration['table_name']),
'COMMIT;',
];
}