|
4 | 4 | namespace Netlogix\Migrations\Command; |
5 | 5 |
|
6 | 6 | use Doctrine\DBAL\Connection; |
| 7 | +use Doctrine\DBAL\Platforms\MySqlPlatform; |
7 | 8 | use Doctrine\ORM\EntityManagerInterface; |
8 | 9 | use Neos\Flow\Annotations as Flow; |
9 | 10 | use Neos\Flow\Cli\CommandController; |
@@ -121,12 +122,19 @@ protected function increaseDatabaseTimeout($timeout = 3600): void |
121 | 122 | { |
122 | 123 | ini_set('default_socket_timeout', (string)$timeout); |
123 | 124 | if (!$this->entityManager instanceof EntityManagerInterface) { |
124 | | - throw new RuntimeException('No Doctrine EntityManager found, cannot increase MySQL timeout'); |
| 125 | + throw new RuntimeException('No Doctrine EntityManager found, cannot increase database timeout'); |
125 | 126 | } |
126 | 127 | $connection = $this->entityManager->getConnection(); |
127 | 128 | if (!$connection || !$connection instanceof Connection) { |
128 | | - throw new RuntimeException('No Doctrine Connection found, cannot increase MySQL timeout'); |
| 129 | + throw new RuntimeException('No Doctrine Connection found, cannot increase database timeout'); |
| 130 | + } |
| 131 | + |
| 132 | + if ($connection->getDatabasePlatform() instanceof MySqlPlatform) { |
| 133 | + $connection->executeStatement(sprintf('SET SESSION wait_timeout = %d;', $timeout)); |
| 134 | + } elseif ($connection->getDatabasePlatform()->getName() === 'postgresql') { |
| 135 | + $connection->executeStatement(sprintf('SET SESSION statement_timeout = %d;', $timeout * 1000)); |
| 136 | + } else { |
| 137 | + $this->outputLine('<error>Unsupported database platform "%s", cannot increase database timeout</error>', [$connection->getDatabasePlatform()->getName()]); |
129 | 138 | } |
130 | | - $connection->exec(sprintf('SET SESSION wait_timeout = %d;', $timeout)); |
131 | 139 | } |
132 | 140 | } |
0 commit comments