Skip to content

Commit 03dd0ee

Browse files
committed
Fixed determining the driver of the database
1 parent 27120b9 commit 03dd0ee

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
All Notable changes to `laravel-backup` will be documented in this file
44

5+
###2.8.1
6+
- Fixed determining the driver of the database.
7+
58
###2.8.0
69
- The temp backup file will now be explicitly deleted.
710

src/BackupHandlers/Database/DatabaseBackupHandler.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,23 @@ public function __construct(DatabaseBuilder $databaseBuilder)
1717
/**
1818
* Get database configuration.
1919
*
20-
* @param string $database
20+
* @param string $connectionName
2121
*
2222
* @return mixed
2323
*
2424
* @throws Exception
2525
*/
26-
public function getDatabase($database = '')
26+
public function getDatabase($connectionName = '')
2727
{
28-
$database = $database ?: config('database.default');
28+
$connectionName = $connectionName ?: config('database.default');
2929

30-
if ($database != 'mysql') {
30+
$dbDriver = config("database.connections.{$connectionName}.driver");
31+
32+
if ($dbDriver != 'mysql') {
3133
throw new Exception('laravel-backup can only backup mysql databases');
3234
}
3335

34-
return $this->databaseBuilder->getDatabase(config('database.connections.'.$database));
36+
return $this->databaseBuilder->getDatabase(config("database.connections.{$connectionName}"));
3537
}
3638

3739
public function getDumpedDatabase()

tests/MySQLDatabaseTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ public function setUp()
1515
$this->console = m::mock('Spatie\Backup\Console');
1616

1717
$this->database = new MySQLDatabase(
18-
$this->console, 'testDatabase', 'testUser', 'password', 'localhost', '3306', '/var/run/mysqld/mysqld.sock'
18+
$this->console,
19+
'testDatabase',
20+
'testUser',
21+
'password',
22+
'localhost',
23+
'3306',
24+
'/var/run/mysqld/mysqld.sock'
1925
);
2026
}
2127

0 commit comments

Comments
 (0)