Set the logging level to info during automigrate

This commit is contained in:
Melody Becker 2025-04-16 16:41:37 +02:00
parent 02c2e53c51
commit d81a06308a
Signed by: mstar
SSH key fingerprint: SHA256:9VAo09aaVNTWKzPW7Hq2LW+ox9OdwmTSHRoD4mlz1yI

View file

@ -6,6 +6,7 @@ import (
"git.mstar.dev/mstar/goutils/other"
"git.mstar.dev/mstar/goutils/sliceutils"
"github.com/rs/zerolog"
"gorm.io/gorm"
"git.mstar.dev/mstar/linstrom/storage-new/models"
@ -13,6 +14,11 @@ import (
// Auto-migrate all tables and types used
func Migrate(db *gorm.DB) error {
// Shut up gorm's queries during automigrate by setting log level to info during migration
// and then back to the previous value on exit
currentLogLevel := zerolog.GlobalLevel()
zerolog.SetGlobalLevel(zerolog.InfoLevel)
defer zerolog.SetGlobalLevel(currentLogLevel)
if err := createAccountAuthMethodType(db); err != nil {
return other.Error("storage", "Failed to create Auth Method type", err)
}