|
@@ -14,30 +14,28 @@ trait DatabaseTransactionHelpers
|
|
|
{
|
|
|
private function startDbTransaction()
|
|
|
{
|
|
|
- $connections = array_keys(config('database.connections', []));
|
|
|
+ $connection = config('database.default', 'mysql');
|
|
|
|
|
|
- wait(parallelMap($connections, function ($connection) {
|
|
|
- try {
|
|
|
- $driver = app('db')->connection($connection);
|
|
|
+ try {
|
|
|
+ $driver = app('db')->connection($connection);
|
|
|
|
|
|
- if (self::driverSupportsTransactions($driver)) {
|
|
|
- $driver->beginTransaction();
|
|
|
+ if (self::driverSupportsTransactions($driver)) {
|
|
|
+ $driver->beginTransaction();
|
|
|
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- $driverClassName = get_class($driver);
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- if ($this->shouldAllowDatabasePersistence($driverClassName)) {
|
|
|
- throw DatabaseTransactionsNotSupported::create($connection, $driverClassName);
|
|
|
- }
|
|
|
+ $driverClassName = get_class($driver);
|
|
|
|
|
|
- c::warn("Database driver [$driverClassName] for the connection [{$connection}] does not support transactions. Any changes made to your database will persist.");
|
|
|
- } catch (ScribeException $e) {
|
|
|
- throw $e;
|
|
|
- } catch (Exception $e) {
|
|
|
+ if ($this->shouldAllowDatabasePersistence($driverClassName)) {
|
|
|
+ throw DatabaseTransactionsNotSupported::create($connection, $driverClassName);
|
|
|
}
|
|
|
- }));
|
|
|
+
|
|
|
+ c::warn("Database driver [$driverClassName] for the connection [{$connection}] does not support transactions. Any changes made to your database will persist.");
|
|
|
+ } catch (ScribeException $e) {
|
|
|
+ throw $e;
|
|
|
+ } catch (Exception $e) {
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -45,23 +43,21 @@ trait DatabaseTransactionHelpers
|
|
|
*/
|
|
|
private function endDbTransaction()
|
|
|
{
|
|
|
- $connections = array_keys(config('database.connections', []));
|
|
|
+ $connection = config('database.default', 'mysql');
|
|
|
|
|
|
- wait(parallelMap($connections, function ($connection) {
|
|
|
- try {
|
|
|
- $driver = app('db')->connection($connection);
|
|
|
+ try {
|
|
|
+ $driver = app('db')->connection($connection);
|
|
|
|
|
|
- if (self::driverSupportsTransactions($driver)) {
|
|
|
- $driver->rollBack();
|
|
|
+ if (self::driverSupportsTransactions($driver)) {
|
|
|
+ $driver->rollBack();
|
|
|
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- $driverClassName = get_class($driver);
|
|
|
- c::warn("Database driver [$driverClassName] for the connection [{$connection}] does not support transactions. Any changes made to your database have been persisted.");
|
|
|
- } catch (Exception $e) {
|
|
|
+ return;
|
|
|
}
|
|
|
- }));
|
|
|
+
|
|
|
+ $driverClassName = get_class($driver);
|
|
|
+ c::warn("Database driver [$driverClassName] for the connection [{$connection}] does not support transactions. Any changes made to your database have been persisted.");
|
|
|
+ } catch (Exception $e) {
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private static function driverSupportsTransactions($driver): bool
|