Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] Allow setting synchronous_commit for Postgres #33897

Merged
merged 1 commit into from Aug 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/Illuminate/Database/Connectors/PostgresConnector.php
Expand Up @@ -47,6 +47,8 @@ public function connect(array $config)
// determine if the option has been specified and run a statement if so.
$this->configureApplicationName($connection, $config);

$this->configureSynchronousCommit($connection, $config);

return $connection;
}

Expand Down Expand Up @@ -173,4 +175,20 @@ protected function addSslOptions($dsn, array $config)

return $dsn;
}

/**
* Configure the synchronous_commit setting.
*
* @param \PDO $connection
* @param array $config
* @return void
*/
protected function configureSynchronousCommit($connection, array $config)
{
if (! isset($config['synchronous_commit'])) {
return;
}

$connection->prepare("set synchronous_commit to '{$config['synchronous_commit']}'")->execute();
}
}