Merge pull request 'fix' (#17) from master into dev

Reviewed-on: https://gitea.chocomarsh.com/self/monitoring/pulls/17
This commit is contained in:
emmatveev 2025-06-13 23:32:30 +03:00
commit 703549703b

View File

@ -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
}
}