Skip to content

Commit

Permalink
add postgresql support
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Mar 13, 2016
1 parent ada8125 commit bbc6f68
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"illuminate/filesystem": "^5.1.20",
"league/flysystem": "^1.0.8",
"symfony/finder": "^2.7|^3.0",
"spatie/db-dumper": "^1.1.0"
"spatie/db-dumper": "^1.2.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8",
Expand Down
34 changes: 19 additions & 15 deletions src/Tasks/Backup/BackupJobFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Spatie\Backup\BackupDestination\BackupDestinationFactory;
use Spatie\Backup\Exceptions\InvalidConfiguration;
use Spatie\DbDumper\Databases\MySql;
use Spatie\DbDumper\Databases\PostgreSql;

class BackupJobFactory
{
Expand Down Expand Up @@ -45,24 +46,27 @@ protected static function getDbDumpers(array $dbConnectionNames)

$dbConfig = config("database.connections.{$dbConnectionName}");

if (! in_array($dbConfig['driver'], ['mysql', 'pgsql'])) {
throw InvalidConfiguration::cannotUseUnsupportedDriver($dbConnectionName, $dbConfig['driver']);
}
switch ($dbConfig['driver']) {
case 'mysql':
return MySql::create()
->setHost($dbConfig['host'])
->setDbName($dbConfig['database'])
->setUserName($dbConfig['username'])
->setPassword($dbConfig['password']);
break;

if ($dbConfig['driver'] === 'pgsql') {
case 'pgsql':
return PostgreSql::create()
->setHost($dbConfig['host'])
->setDbName($dbConfig['database'])
->setUserName($dbConfig['username'])
->setPassword($dbConfig['password']);
break;

/**
* @todo: add postgres dumper
*/
return;
default:
throw InvalidConfiguration::cannotUseUnsupportedDriver($dbConnectionName, $dbConfig['driver']);
break;
}

return MySql::create()
->setHost($dbConfig['host'])
->setDbName($dbConfig['database'])
->setUserName($dbConfig['username'])
->setPassword($dbConfig['password']);

}, $dbConnectionNames);

return $dbDumpers;
Expand Down

0 comments on commit bbc6f68

Please sign in to comment.