next try
All checks were successful
GoLang Tests / Run Go Tests (push) Successful in 2m2s
GoLang Tests / Build Go Image and Upload (push) Successful in 2m34s

This commit is contained in:
2025-08-21 23:34:31 +02:00
parent 92349dc7d2
commit 119c0c3b33
4 changed files with 59 additions and 4 deletions

View File

@@ -5,6 +5,10 @@ import (
"arbeitszeitmessung/models"
"database/sql"
"fmt"
"log"
"github.com/golang-migrate/migrate/v4"
_ "github.com/golang-migrate/migrate/v4/source/file"
)
func OpenDatabase() (models.IDatabase, error) {
@@ -21,3 +25,11 @@ func OpenDatabase() (models.IDatabase, error) {
defer db.Close()
return db, err
}
func MigrateDB(db models.IDatabase, connStr string) {
m, err := migrate.New("file:///../migrations/", connStr)
if err != nil {
log.Fatalln("Error starting migration", err)
}
m.Up()
}