Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.x] Only support MariaDB 11 #707

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 7 additions & 19 deletions src/Console/Concerns/InteractsWithDockerComposeServices.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ trait InteractsWithDockerComposeServices
protected $services = [
'mysql',
'pgsql',
'mariadb10',
'mariadb11',
'mariadb',
'redis',
'memcached',
'meilisearch',
Expand Down Expand Up @@ -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';
}

Expand All @@ -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']);
}
Expand All @@ -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'];
});

Expand Down Expand Up @@ -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',
Expand All @@ -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);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ public function handle()
$this->output->writeln('<fg=gray>➜</> <options=bold>./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:');

Expand Down
File renamed without changes.
20 changes: 0 additions & 20 deletions stubs/mariadb10.stub

This file was deleted.