fix migration
Deploy / deploy (push) Successful in 10s

This commit is contained in:
2026-05-31 20:48:22 +02:00
parent 0d61e623a7
commit 2f2037f4da
+20 -1
View File
@@ -167,7 +167,26 @@ class ClickHouseClient
public function migrate(): void
{
$this->execute("CREATE DATABASE IF NOT EXISTS {$this->database}");
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $this->url() . '?' . http_build_query(['database' => 'default']),
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => "CREATE DATABASE IF NOT EXISTS {$this->database}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => $this->timeout,
CURLOPT_CONNECTTIMEOUT => $this->timeout,
CURLOPT_HTTPHEADER => ['Content-Type: text/plain'],
]);
if ($this->username) {
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $this->username . ':' . $this->password);
}
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode !== 200 && !str_contains($response, 'already exists')) {
throw new \RuntimeException("ClickHouse error (HTTP $httpCode): $response");
}
$this->execute("
CREATE TABLE IF NOT EXISTS log_entries (