Skip to content

Commit

Permalink
Fixed determining the driver of the database
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Nov 5, 2015
1 parent 27120b9 commit 03dd0ee
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

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

###2.8.1
- Fixed determining the driver of the database.

###2.8.0
- The temp backup file will now be explicitly deleted.

Expand Down
12 changes: 7 additions & 5 deletions src/BackupHandlers/Database/DatabaseBackupHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,23 @@ public function __construct(DatabaseBuilder $databaseBuilder)
/**
* Get database configuration.
*
* @param string $database
* @param string $connectionName
*
* @return mixed
*
* @throws Exception
*/
public function getDatabase($database = '')
public function getDatabase($connectionName = '')
{
$database = $database ?: config('database.default');
$connectionName = $connectionName ?: config('database.default');

if ($database != 'mysql') {
$dbDriver = config("database.connections.{$connectionName}.driver");

if ($dbDriver != 'mysql') {
throw new Exception('laravel-backup can only backup mysql databases');
}

return $this->databaseBuilder->getDatabase(config('database.connections.'.$database));
return $this->databaseBuilder->getDatabase(config("database.connections.{$connectionName}"));
}

public function getDumpedDatabase()
Expand Down
8 changes: 7 additions & 1 deletion tests/MySQLDatabaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ public function setUp()
$this->console = m::mock('Spatie\Backup\Console');

$this->database = new MySQLDatabase(
$this->console, 'testDatabase', 'testUser', 'password', 'localhost', '3306', '/var/run/mysqld/mysqld.sock'
$this->console,
'testDatabase',
'testUser',
'password',
'localhost',
'3306',
'/var/run/mysqld/mysqld.sock'
);
}

Expand Down

0 comments on commit 03dd0ee

Please sign in to comment.