BREAKING CHANGE: V2 of thr SDK #12
@ -5,7 +5,6 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
"embed"
|
"embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"git.dragse.it/anthrove/otter-space-sdk/internal/postgres"
|
"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/internal/utils"
|
||||||
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
|
||||||
@ -21,12 +20,14 @@ import (
|
|||||||
var embedMigrations embed.FS
|
var embedMigrations embed.FS
|
||||||
|
|
||||||
type postgresqlConnection struct {
|
type postgresqlConnection struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
|
debug bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPostgresqlConnection() OtterSpace {
|
func NewPostgresqlConnection(debugOutput bool) OtterSpace {
|
||||||
return &postgresqlConnection{
|
return &postgresqlConnection{
|
||||||
db: nil,
|
db: nil,
|
||||||
|
debug: debugOutput,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,12 +171,15 @@ func (p *postgresqlConnection) migrateDatabase(connectionString string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("postgres migration: %v", err)
|
return fmt.Errorf("postgres migration: %v", err)
|
||||||
}
|
}
|
||||||
if n != 0 {
|
|
||||||
log.Tracef("postgres migration: applied %d migrations!", n)
|
|
||||||
|
|
||||||
} else {
|
if p.debug {
|
||||||
log.Trace("postgres migration: nothing to migrate")
|
if n != 0 {
|
||||||
|
log.Infof("postgres migration: applied %d migrations!", n)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
log.Info("postgres migration: nothing to migrate")
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Reference in New Issue
Block a user