Files
coolify/app/Traits/ExecutesDatabaseStartCommands.php
T
Andras Bacsai 8e0f4d0dfa fix(database): prevent duplicate environment variables on start and clone
- Stop the Redis username accessor from creating REDIS_USERNAME on read
- Keep source values when cloning applications (no duplicate NIXPACKS_NODE_VERSION)
- Match exact keys when adding default database environment variables
- Write content files before database containers start
- Resolve the database proxy upstream through Docker DNS on each connection
- Remove existing duplicate REDIS_USERNAME and NIXPACKS_NODE_VERSION rows
2026-10-09 14:53:05 +02:00

31 lines
1.0 KiB
PHP

<?php
namespace App\Traits;
use App\Services\DatabaseStartCommandExecutor;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Spatie\Activitylog\Models\Activity;
trait ExecutesDatabaseStartCommands
{
private function executeDatabaseStartCommands(array $commands, Model $database, ?Activity $activity = null): Activity
{
if ($activity) {
return app(DatabaseStartCommandExecutor::class)->execute($commands, $database, $activity);
}
return remote_process($commands, $database->destination->server, callEventOnFinish: 'DatabaseStatusChanged', queue: deployment_queue());
}
/**
* Whether a `KEY=value` list already defines the exact key (not just a key or value containing it).
*
* @param Collection<int, string> $environmentVariables
*/
private function hasEnvironmentVariable(Collection $environmentVariables, string $key): bool
{
return $environmentVariables->contains(fn ($variable) => str($variable)->before('=')->value() === $key);
}
}