From 5ba0be8e309050e788650bb8d82123d769e50139 Mon Sep 17 00:00:00 2001 From: Egor Matveev Date: Fri, 13 Jun 2025 23:30:59 +0300 Subject: [PATCH] fix --- app/storage/clickhouse/client.go | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/app/storage/clickhouse/client.go b/app/storage/clickhouse/client.go index c615793..e641b23 100644 --- a/app/storage/clickhouse/client.go +++ b/app/storage/clickhouse/client.go @@ -27,7 +27,7 @@ func Close() { func connect() (*driver.Conn, error) { var ( - ctx = context.Background() + ctx = context.Background() conn, err = clickhouse.Open(&clickhouse.Options{ Addr: []string{"clickhouse:9000"}, Auth: clickhouse.Auth{ @@ -54,7 +54,7 @@ func connect() (*driver.Conn, error) { func Migrate() error { err := Connection.Exec( - context.TODO(), + context.TODO(), `CREATE TABLE IF NOT EXISTS endpoints ( timestamp DateTime, service_name LowCardinality(String), @@ -67,9 +67,27 @@ func Migrate() error { PARTITION BY toYYYYMM(timestamp) ORDER BY (service_name, endpoint, request_method, timestamp);`, ) - if err != nil { - log.Fatal(err) + if err != nil { + log.Fatal(err) return err - } + } + + err = Connection.Exec( + context.TODO(), + `CREATE TABLE IF NOT EXISTS tasks ( + timestamp DateTime, + service_name LowCardinality(String), + queue_name LowCardinality(String), + success Bool, + execution_time_ms UInt32 + ) + ENGINE = MergeTree + PARTITION BY toYYYYMM(timestamp) + ORDER BY (service_name, queue_name, timestamp);`, + ) + if err != nil { + log.Fatal(err) + return err + } return nil -} \ No newline at end of file +}