Skip to content

Commit

Permalink
fix(db): logging
Browse files Browse the repository at this point in the history
Extend logging to tell us exactly which migration triggered a git pull

Ref: SRX-RH7CD5
  • Loading branch information
sven-urbanski-freiheit-com committed Oct 2, 2024
1 parent 2d7a508 commit 2bcd9fe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -2586,7 +2586,11 @@ func (h *DBHandler) NeedsMigrations(ctx context.Context) (bool, error) {
if err != nil {
return err
}
if !needs {
logger.FromContext(ctx).Sugar().Warnf("migration skipped: %v", i)
}
if needs {
logger.FromContext(ctx).Sugar().Warnf("migration required: %v", i)
needsMigration = true
return nil
}
Expand Down
2 changes: 2 additions & 0 deletions services/cd-service/pkg/cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,9 @@ func RunServer() {
}
if dbHandler.ShouldUseOtherTables() {
//Check for migrations -> for pulling
logger.FromContext(ctx).Sugar().Warnf("checking if migrations are required...")
if needsMigration, err := dbHandler.NeedsMigrations(ctx); err == nil && needsMigration {
logger.FromContext(ctx).Sugar().Warnf("starting to pull the repo")
err := repo.Pull(ctx)
if err != nil {
logger.FromContext(ctx).Fatal("Could not pull repository to perform custom migrations", zap.Error(err))
Expand Down

0 comments on commit 2bcd9fe

Please sign in to comment.