Improve live DB clone speed

This commit is contained in:
Jeppe Bundgaard
2026-03-12 13:26:22 +01:00
parent e91dda0799
commit 5cb197898d
12 changed files with 3510 additions and 34 deletions
+25 -7
View File
@@ -68,15 +68,33 @@ if (isset($_ENV['USE_ENV']) && $_ENV['USE_ENV'] === 'true') {
'REDIS_CONFIG_DATABASE' => 'database',
'REDIS_CONFIG_PASSWORD' => 'password'
];
$dbTarget = strtolower(trim((string)($_ENV['CONFIG_DB_TARGET'] ?? 'live')));
if ($dbTarget !== 'live' && $dbTarget !== 'debug') {
$dbTarget = 'live';
}
$resolveDbValue = function (string $key) use ($dbTarget): string {
$liveKey = 'CONFIG_DB_' . $key;
$debugKey = 'CONFIG_DB_DEBUG_' . $key;
$liveValue = (string)($_ENV[$liveKey] ?? '');
$debugValue = (string)($_ENV[$debugKey] ?? '');
if ($dbTarget === 'debug' && $debugValue !== '') {
return $debugValue;
}
return $liveValue;
};
/**
* Set the db configuration
* Set the db configuration from selected target (live/debug)
*/
$CONFIG_DB = [
'host' => $_ENV['CONFIG_DB_HOST'],
'user' => $_ENV['CONFIG_DB_USER'],
'password' => $_ENV['CONFIG_DB_PASSWORD'],
'database' => $_ENV['CONFIG_DB_DATABASE'],
'ssl_mode' => $_ENV['CONFIG_DB_SSL_MODE'] ?? 'DISABLED'
'host' => $resolveDbValue('HOST'),
'user' => $resolveDbValue('USER'),
'password' => $resolveDbValue('PASSWORD'),
'database' => $resolveDbValue('DATABASE'),
'ssl_mode' => $resolveDbValue('SSL_MODE') !== '' ? $resolveDbValue('SSL_MODE') : 'DISABLED'
];
/**
* Set the debug configuration
@@ -134,4 +152,4 @@ if (isset($_ENV['USE_ENV']) && $_ENV['USE_ENV'] === 'true') {
// Set the timezone
date_default_timezone_set($_ENV['CONFIG_TIMEZONE']) ?? 'Europe/Copenhagen';
}
}