diff --git a/.version b/.version index 1981190..f280719 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -3.8.0 +3.8.1 diff --git a/changelog.md b/changelog.md index 6a190f2..c2ccfe1 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,5 @@ +### v3.8.1 +* исправлена миграция для `config-history` ### v3.8.0 * Добавлен новый endpoint `config/schema/update_by_module_name` для обновления схемы модуля по его названию ## v3.7.0 diff --git a/cmd/migrate/main.go b/cmd/migrate/main.go index fb8a288..7fe25cc 100644 --- a/cmd/migrate/main.go +++ b/cmd/migrate/main.go @@ -167,7 +167,7 @@ func main() { AdminId: 0, CreatedAt: xtypes.Time(history.CreatedAt), } - err := configHistoryRepo.Insert(ctx, result) + err := configHistoryRepo.InsertV2(ctx, result) if err != nil { panic(errors.WithMessagef(err, "err inserting config_history: %s", history.Id)) } @@ -194,7 +194,7 @@ func main() { Header("Content-Type", "application/octet-stream"). RequestBody(sqliteFile). StatusCodeToError(). - Timeout(60 * time.Second). + Timeout(120 * time.Second). DoWithoutResponse(ctx) if err != nil { panic(errors.WithMessage(err, "load sqlite file")) diff --git a/repository/config_history.go b/repository/config_history.go index 1a95623..0a9e181 100644 --- a/repository/config_history.go +++ b/repository/config_history.go @@ -44,6 +44,25 @@ func (r ConfigHistory) Delete(ctx context.Context, id string) error { return nil } +func (r ConfigHistory) InsertV2(ctx context.Context, history entity.ConfigHistory) error { + ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigHistory.InsertV2") + + 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). + ToSql() + if err != nil { + return errors.WithMessage(err, "build query") + } + + _, err = r.db.Exec(ctx, query, args...) + if err != nil { + return errors.WithMessagef(err, "exec: %s", query) + } + + return nil +} + func (r ConfigHistory) Insert(ctx context.Context, history entity.ConfigHistory) error { ctx = sql_metrics.OperationLabelToContext(ctx, "ConfigHistory.Insert")