From d56d6613bb39c7bb8c0f884cd2100bb9180cc4e2 Mon Sep 17 00:00:00 2001 From: yankomissarov Date: Tue, 8 Jul 2025 11:18:15 +0300 Subject: [PATCH] Call upsert variables in any case --- .version | 2 +- Dockerfile | 2 +- changelog.md | 4 ++++ repository/config_history.go | 4 ++-- repository/variable.go | 1 + service/variable/service.go | 4 ---- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.version b/.version index 1809198..47b322c 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -3.4.0 +3.4.1 diff --git a/Dockerfile b/Dockerfile index 04d4217..2410a32 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ RUN go build -ldflags="-X 'main.version=$version_env'" -o /main . WORKDIR cmd/migrate RUN CGO_ENABLED=1 go build -o /migrate . -FROM alpine:3.21 +FROM alpine:3.22 RUN apk add --no-cache tzdata RUN cp /usr/share/zoneinfo/Europe/Moscow /etc/localtime diff --git a/changelog.md b/changelog.md index 62c8567..372dd72 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,7 @@ +## v3.4.1 +* исправлена проблема при которой не отвязывалась единственная переменная от конфигурации +* исправлена проблема при которой версия конфига сохраняется с некорректным временем (бралось текущее время, а не время обновления конфига) +* обновлены зависимости ## v3.4.0 * добавлено поле `metrics_autodiscovery` в таблицу `isp_config_service__backend` * реализован внутренний метод `/internal/metrics/autodiscovery`, формирующий конфигурацию для `HTTP-based service discovery` механизма `Prometheus` diff --git a/repository/config_history.go b/repository/config_history.go index 606cc3f..1a95623 100644 --- a/repository/config_history.go +++ b/repository/config_history.go @@ -48,8 +48,8 @@ func (r ConfigHistory) Insert(ctx context.Context, history entity.ConfigHistory) ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigHistory.Insert") query, args, err := squirrel.Insert(Table("config_history")). - Columns("id", "config_id", "data", "version", "admin_id"). - Values(history.Id, history.ConfigId, history.Data, history.Version, history.AdminId). + Columns("id", "config_id", "data", "version", "admin_id", "created_at"). + Values(history.Id, history.ConfigId, history.Data, history.Version, history.AdminId, history.CreatedAt). ToSql() if err != nil { return errors.WithMessage(err, "build query") diff --git a/repository/variable.go b/repository/variable.go index c87dbb2..3dafb0a 100644 --- a/repository/variable.go +++ b/repository/variable.go @@ -146,6 +146,7 @@ func (r Variable) UpsertLinks(ctx context.Context, configId string, links []enti requests := [][]any{ db.Request(deleteQuery, args...), } + for _, variable := range links { query, args, err := squirrel.Insert(Table("config_has_variable")). Columns("config_id", "variable_name"). diff --git a/service/variable/service.go b/service/variable/service.go index 30756b0..0bd845a 100644 --- a/service/variable/service.go +++ b/service/variable/service.go @@ -255,10 +255,6 @@ func (s Service) ExtractVariables(ctx context.Context, configId string, input [] } func (s Service) SaveVariableLinks(ctx context.Context, configId string, links []entity.ConfigHasVariable) error { - if len(links) == 0 { - return nil - } - err := s.repo.UpsertLinks(ctx, configId, links) if err != nil { return errors.WithMessage(err, "upsert links")