From c84e7b8f553e6420cb4bd19bfd345e46de6ce383 Mon Sep 17 00:00:00 2001 From: Julius Kiekbusch Date: Mon, 22 Jul 2024 10:44:15 +0200 Subject: [PATCH] Only support MariaDB 11 --- .../InteractsWithDockerComposeServices.php | 26 +++++-------------- src/Console/InstallCommand.php | 3 +-- stubs/{mariadb11.stub => mariadb.stub} | 0 stubs/mariadb10.stub | 20 -------------- 4 files changed, 8 insertions(+), 41 deletions(-) rename stubs/{mariadb11.stub => mariadb.stub} (100%) delete mode 100644 stubs/mariadb10.stub diff --git a/src/Console/Concerns/InteractsWithDockerComposeServices.php b/src/Console/Concerns/InteractsWithDockerComposeServices.php index db290d9f..0404525b 100644 --- a/src/Console/Concerns/InteractsWithDockerComposeServices.php +++ b/src/Console/Concerns/InteractsWithDockerComposeServices.php @@ -15,8 +15,7 @@ trait InteractsWithDockerComposeServices protected $services = [ 'mysql', 'pgsql', - 'mariadb10', - 'mariadb11', + 'mariadb', 'redis', 'memcached', 'meilisearch', @@ -67,7 +66,7 @@ protected function buildDockerCompose(array $services) : Yaml::parse(file_get_contents(__DIR__ . '/../../../stubs/docker-compose.stub')); // Prepare the installation of the "mariadb-client" package if the MariaDB service is used... - if (in_array('mariadb10', $services) || in_array('mariadb11', $services)) { + if (in_array('mariadb', $services)) { $compose['services']['laravel.test']['build']['args']['MYSQL_CLIENT'] = 'mariadb-client'; } @@ -83,12 +82,8 @@ protected function buildDockerCompose(array $services) } // Update the dependencies if the MariaDB service is used... - if (in_array('mariadb10', $services) || in_array('mariadb11', $services)) { + if (in_array('mariadb', $services)) { $compose['services']['laravel.test']['depends_on'] = array_map(function ($dependedItem) { - if (in_array($dependedItem, ['mariadb10', 'mariadb11'])) { - return 'mariadb'; - } - return $dependedItem; }, $compose['services']['laravel.test']['depends_on']); } @@ -98,22 +93,16 @@ protected function buildDockerCompose(array $services) ->filter(function ($service) use ($compose) { return ! array_key_exists($service, $compose['services'] ?? []); })->each(function ($service) use (&$compose) { - in_array($service, ['mariadb10', 'mariadb11']) - ? $compose['services']['mariadb'] = Yaml::parseFile(__DIR__ . "/../../../stubs/{$service}.stub")['mariadb'] - : $compose['services'][$service] = Yaml::parseFile(__DIR__ . "/../../../stubs/{$service}.stub")[$service]; + $compose['services'][$service] = Yaml::parseFile(__DIR__ . "/../../../stubs/{$service}.stub")[$service]; }); // Merge volumes... collect($services) ->filter(function ($service) { - return in_array($service, ['mysql', 'pgsql', 'mariadb10', 'mariadb11', 'redis', 'meilisearch', 'typesense', 'minio']); + return in_array($service, ['mysql', 'pgsql', 'mariadb', 'redis', 'meilisearch', 'typesense', 'minio']); })->filter(function ($service) use ($compose) { return ! array_key_exists($service, $compose['volumes'] ?? []); })->each(function ($service) use (&$compose) { - if (in_array($service, ['mariadb10', 'mariadb11'])) { - $service = 'mariadb'; - } - $compose['volumes']["sail-{$service}"] = ['driver' => 'local']; }); @@ -141,8 +130,7 @@ protected function replaceEnvVariables(array $services) $environment = file_get_contents($this->laravel->basePath('.env')); if (in_array('mysql', $services) || - in_array('mariadb10', $services) || - in_array('mariadb11', $services) || + in_array('mariadb', $services) || in_array('pgsql', $services)) { $defaults = [ '# DB_HOST=127.0.0.1', @@ -164,7 +152,7 @@ protected function replaceEnvVariables(array $services) $environment = preg_replace('/DB_CONNECTION=.*/', 'DB_CONNECTION=pgsql', $environment); $environment = str_replace('DB_HOST=127.0.0.1', "DB_HOST=pgsql", $environment); $environment = str_replace('DB_PORT=3306', "DB_PORT=5432", $environment); - } elseif (in_array('mariadb10', $services) || in_array('mariadb11', $services)) { + } elseif (in_array('mariadb', $services)) { if ($this->laravel->config->has('database.connections.mariadb')) { $environment = preg_replace('/DB_CONNECTION=.*/', 'DB_CONNECTION=mariadb', $environment); } diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index 2c4b805e..9b197ee7 100644 --- a/src/Console/InstallCommand.php +++ b/src/Console/InstallCommand.php @@ -65,8 +65,7 @@ public function handle() $this->output->writeln('./vendor/bin/sail up'); if (in_array('mysql', $services) || - in_array('mariadb10', $services) || - in_array('mariadb11', $services) || + in_array('mariadb', $services) || in_array('pgsql', $services)) { $this->components->warn('A database service was installed. Run "artisan migrate" to prepare your database:'); diff --git a/stubs/mariadb11.stub b/stubs/mariadb.stub similarity index 100% rename from stubs/mariadb11.stub rename to stubs/mariadb.stub diff --git a/stubs/mariadb10.stub b/stubs/mariadb10.stub deleted file mode 100644 index 61da5420..00000000 --- a/stubs/mariadb10.stub +++ /dev/null @@ -1,20 +0,0 @@ -mariadb: - image: 'mariadb:10' - ports: - - '${FORWARD_DB_PORT:-3306}:3306' - environment: - MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}' - MYSQL_ROOT_HOST: "%" - MYSQL_DATABASE: '${DB_DATABASE}' - MYSQL_USER: '${DB_USERNAME}' - MYSQL_PASSWORD: '${DB_PASSWORD}' - MYSQL_ALLOW_EMPTY_PASSWORD: 'yes' - volumes: - - 'sail-mariadb:/var/lib/mysql' - - './vendor/laravel/sail/database/mariadb/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh' - networks: - - sail - healthcheck: - test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] - retries: 3 - timeout: 5s