repair package names and other fixed

This commit is contained in:
Daniel Goc
2026-03-11 14:17:26 +01:00
parent b6a50ec1ca
commit 4450468145
39 changed files with 128 additions and 119 deletions

View File

@@ -5,9 +5,9 @@ import (
"log"
"log/slog"
"git.ma-al.com/goc_marek/timetracker/app/config"
"git.ma-al.com/goc_daniel/b2b/app/config"
"gorm.io/driver/postgres"
"gorm.io/driver/mysql"
"gorm.io/gorm"
"gorm.io/gorm/logger"
)
@@ -16,7 +16,7 @@ var DB *gorm.DB
func init() {
if DB == nil {
dbconn, err := newPostgresDB(&config.Get().Database)
dbconn, err := newMySQLDB(&config.Get().Database)
if err != nil {
slog.Error("⚠️ No connection to database was possible to establish", "error", err.Error())
}
@@ -28,11 +28,12 @@ func Get() *gorm.DB {
return DB
}
// newPostgresDB creates a new PostgreSQL database connection
func newPostgresDB(cfg *config.DatabaseConfig) (*gorm.DB, error) {
// newMySQLDB creates a new MariaDB/MySQL database connection
func newMySQLDB(cfg *config.DatabaseConfig) (*gorm.DB, error) {
dsn := cfg.GetDSN()
db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{
db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{
Logger: logger.Default.LogMode(logger.Error),
})
@@ -51,6 +52,7 @@ func newPostgresDB(cfg *config.DatabaseConfig) (*gorm.DB, error) {
sqlDB.SetConnMaxLifetime(cfg.ConnMaxLifetime)
log.Println("✓ Database connection established successfully")
return db, nil
}