Skip to content

Commit ab7580b

Browse files
NiroDeveloperfreekmurze
authored andcommitted
Use MariaDb dumper
The spatie/laravel-backup package currently uses MySQL dumper for all MySQL-compatible databases, including MariaDB. However, MariaDB has deprecated the mysqldump utility in favor of mariadb-dump as documented in their official documentation. Recently, a dedicated MariaDB dumper was added to the spatie/db-dumper package in PR #220, which properly uses the mariadb-dump utility. This PR updates this package to utilize the new dumper when a MariaDB connection is required. on-behalf-of: @e-solutions-GmbH [email protected]
1 parent 21c5973 commit ab7580b

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"illuminate/notifications": "^10.10.0|^11.0|^12.0",
2828
"illuminate/support": "^10.10.0|^11.0|^12.0",
2929
"league/flysystem": "^3.0",
30-
"spatie/db-dumper": "^3.7",
30+
"spatie/db-dumper": "^3.8",
3131
"spatie/laravel-package-tools": "^1.6.2",
3232
"spatie/laravel-signal-aware-command": "^1.2|^2.0",
3333
"spatie/temporary-directory": "^2.0",

src/Tasks/Backup/DbDumperFactory.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Support\Arr;
88
use Illuminate\Support\Str;
99
use Spatie\Backup\Exceptions\CannotCreateDbDumper;
10+
use Spatie\DbDumper\Databases\MariaDb;
1011
use Spatie\DbDumper\Databases\MongoDb;
1112
use Spatie\DbDumper\Databases\MySql;
1213
use Spatie\DbDumper\Databases\PostgreSql;
@@ -85,7 +86,8 @@ protected static function forDriver(string $dbDriver): DbDumper
8586
}
8687

8788
return match ($driver) {
88-
'mysql', 'mariadb' => new MySql,
89+
'mysql' => new MySql,
90+
'mariadb' => new MariaDb,
8991
'pgsql' => new PostgreSql,
9092
'sqlite' => new Sqlite,
9193
'mongodb' => new MongoDb,

tests/DbDumperFactoryTest.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use Spatie\Backup\Exceptions\CannotCreateDbDumper;
44
use Spatie\Backup\Tasks\Backup\DbDumperFactory;
5+
use Spatie\DbDumper\Databases\MariaDb;
56
use Spatie\DbDumper\Databases\MongoDb;
67
use Spatie\DbDumper\Databases\MySql;
78
use Spatie\DbDumper\Databases\PostgreSql;
@@ -10,6 +11,15 @@
1011
beforeEach(function () {
1112
config()->set('database.default', 'mysql');
1213

14+
config()->set('database.connections.mariadb', [
15+
'driver' => 'mariadb',
16+
'host' => 'localhost',
17+
'port' => 3306,
18+
'database' => 'myDb',
19+
'username' => 'root',
20+
'password' => 'myPassword',
21+
]);
22+
1323
config()->set('database.connections.mongodb', [
1424
'driver' => 'mongodb',
1525
'host' => 'localhost',
@@ -40,8 +50,9 @@
4050
]);
4151
});
4252

43-
it('can create instances of mysql and pgsql and mongodb', function () {
53+
it('can create instances of mysql and mariadb and pgsql and mongodb', function () {
4454
expect(DbDumperFactory::createFromConnection('mysql'))->toBeInstanceOf(MySql::class);
55+
expect(DbDumperFactory::createFromConnection('mariadb'))->toBeInstanceOf(MariaDb::class);
4556
expect(DbDumperFactory::createFromConnection('pgsql'))->toBeInstanceOf(PostgreSql::class);
4657
expect(DbDumperFactory::createFromConnection('mongodb'))->toBeInstanceOf(MongoDb::class);
4758
});

0 commit comments

Comments
 (0)