feat(postgres): added console debug option
This commit is contained in:
parent
b248cbf0c7
commit
a60805fccf
@ -5,7 +5,6 @@ import (
|
||||
"database/sql"
|
||||
"embed"
|
||||
"fmt"
|
||||
|
||||
"git.dragse.it/anthrove/otter-space-sdk/internal/postgres"
|
||||
"git.dragse.it/anthrove/otter-space-sdk/internal/utils"
|
||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
||||
@ -22,11 +21,13 @@ var embedMigrations embed.FS
|
||||
|
||||
type postgresqlConnection struct {
|
||||
db *gorm.DB
|
||||
debug bool
|
||||
}
|
||||
|
||||
func NewPostgresqlConnection() OtterSpace {
|
||||
func NewPostgresqlConnection(debugOutput bool) OtterSpace {
|
||||
return &postgresqlConnection{
|
||||
db: nil,
|
||||
debug: debugOutput,
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,13 +171,16 @@ func (p *postgresqlConnection) migrateDatabase(connectionString string) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("postgres migration: %v", err)
|
||||
}
|
||||
|
||||
if p.debug {
|
||||
if n != 0 {
|
||||
log.Tracef("postgres migration: applied %d migrations!", n)
|
||||
log.Infof("postgres migration: applied %d migrations!", n)
|
||||
|
||||
} else {
|
||||
log.Trace("postgres migration: nothing to migrate")
|
||||
log.Info("postgres migration: nothing to migrate")
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user