Skip to content

Commit

Permalink
fix: return error if migrations fail to run
Browse files Browse the repository at this point in the history
  • Loading branch information
dhawal1248 committed Oct 6, 2023
1 parent 46f0430 commit ad8afed
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions exporter/clickhousetracesexporter/clickhouse_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"flag"
"fmt"
"net/url"
"strings"

"github.com/ClickHouse/clickhouse-go/v2"
"github.com/golang-migrate/migrate/v4"
Expand Down Expand Up @@ -125,10 +126,15 @@ func (f *Factory) Initialize(logger *zap.Logger) error {
}
// enable migration file templating
m.EnableTemplating = true

// run migrations
err = m.Up()
f.logger.Info("Clickhouse Migrate finished", zap.Error(err))
if err != nil && !strings.HasSuffix(err.Error(), "no change") {
f.logger.Error("clickhouse Migrate failed to run", zap.Error(err))
return fmt.Errorf("clickhouse Migrate failed to run, error: %s", err)
}

f.logger.Info("Clickhouse Migrate finished")
return nil
}

Expand Down

0 comments on commit ad8afed

Please sign in to comment.