From fdd958c1e5c7c84c1f1a0f4a5767b488955f926f Mon Sep 17 00:00:00 2001 From: Darko Gjorgjijoski <5760249+gdarko@users.noreply.github.com> Date: Wed, 29 Jul 2026 12:29:01 +0200 Subject: [PATCH] fix(setup): support mariadb in the installation wizard (#704) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes InvoiceShelf/docker#79 — a fresh install using the shipped docker-compose.mysql.yml cannot get past the database step, because that compose file sets DB_CONNECTION=mariadb. getDatabaseEnvironment() switched on sqlite, pgsql and mysql with no arm for mariadb and no default, so it answered {"config":[]}. The wizard chooses which form to render from database_connection in that response, so step 4 rendered blank with no way forward — and nothing reached the log, because the app never errored, it just replied with nothing. Adds the mariadb arm, and a default so an unrecognised driver can never again produce an unrenderable response: it is echoed back with the server defaults, leaving the fields editable rather than the step empty. MariaDB is now offered in the driver dropdown too. It was already a valid DB_CONNECTION with its own connection in config/database.php, and the form fields are identical to MySQL's. Tested against the original code, where three of the new cases fail with "Failed asserting that null is identical to 'mariadb'". --- .../Setup/DatabaseConfigurationController.php | 21 +++++++ .../installation/views/DatabaseView.vue | 1 + .../Setup/DatabaseConfigurationTest.php | 58 +++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 tests/Feature/Setup/DatabaseConfigurationTest.php diff --git a/app/Http/Controllers/Setup/DatabaseConfigurationController.php b/app/Http/Controllers/Setup/DatabaseConfigurationController.php index cccb0c47..612078a3 100644 --- a/app/Http/Controllers/Setup/DatabaseConfigurationController.php +++ b/app/Http/Controllers/Setup/DatabaseConfigurationController.php @@ -77,6 +77,27 @@ class DatabaseConfigurationController extends Controller break; + case 'mariadb': + $databaseData = [ + 'database_connection' => 'mariadb', + 'database_host' => '127.0.0.1', + 'database_port' => 3306, + ]; + + break; + + default: + // Never return an empty config: the wizard picks its form from + // database_connection, so an unrecognised driver used to render + // a blank step with no way forward. Echo it back with the + // server defaults instead. + $databaseData = [ + 'database_connection' => $connection, + 'database_host' => '127.0.0.1', + 'database_port' => 3306, + ]; + + break; } return response()->json([ diff --git a/resources/scripts/features/installation/views/DatabaseView.vue b/resources/scripts/features/installation/views/DatabaseView.vue index d5de3ad5..b2d719b8 100644 --- a/resources/scripts/features/installation/views/DatabaseView.vue +++ b/resources/scripts/features/installation/views/DatabaseView.vue @@ -114,6 +114,7 @@ const isSaving = ref(false) const databaseDrivers = ref([ { label: 'MySQL', value: 'mysql' }, + { label: 'MariaDB', value: 'mariadb' }, { label: 'PostgreSQL', value: 'pgsql' }, { label: 'SQLite', value: 'sqlite' }, ]) diff --git a/tests/Feature/Setup/DatabaseConfigurationTest.php b/tests/Feature/Setup/DatabaseConfigurationTest.php new file mode 100644 index 00000000..5ac3821d --- /dev/null +++ b/tests/Feature/Setup/DatabaseConfigurationTest.php @@ -0,0 +1,58 @@ +assertOk(); + + expect($response->json('config.database_connection'))->toBe($connection); +})->with([ + 'mysql', + 'mariadb', + 'pgsql', + 'sqlite', +]); + +test('sqlite is told where its database file lives', function () { + $response = getJson('/api/v1/installation/database/config?connection=sqlite'); + + $response->assertOk(); + + expect($response->json('config.database_name'))->not->toBeEmpty(); +}); + +test('server-based drivers are given a host and port to prefill', function (string $connection) { + $response = getJson("/api/v1/installation/database/config?connection={$connection}"); + + expect($response->json('config.database_host'))->not->toBeEmpty() + ->and($response->json('config.database_port'))->not->toBeEmpty(); +})->with([ + 'mysql', + 'mariadb', + 'pgsql', +]); + +/** + * A driver we do not recognise must still produce something the wizard can + * render, rather than the empty config that caused #79. + */ +test('an unrecognised driver still returns a renderable config', function () { + $response = getJson('/api/v1/installation/database/config?connection=cockroach'); + + $response->assertOk(); + + expect($response->json('config.database_connection'))->toBe('cockroach') + ->and($response->json('config'))->not->toBeEmpty(); +});