Files
ITWorx Pulse release export bd774932d5
Public source validation / validate (push) Failing after 3m8s
Publish ITWorx Pulse source
2026-09-03 02:09:19 +02:00

37 lines
780 B
Go

package main
import (
"context"
"log/slog"
"os"
"time"
"github.com/itworx/pulse/internal/database"
)
func main() {
logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
defer cancel()
databaseURL := os.Getenv("PULSE_DATABASE_URL")
if databaseURL == "" {
logger.Error("migration failed", "error", "PULSE_DATABASE_URL is required")
os.Exit(1)
}
pool, err := database.NewPool(ctx, database.Config{URL: databaseURL})
if err == nil {
err = database.Ping(ctx, pool)
}
if err == nil {
err = database.Migrate(ctx, pool)
}
if pool != nil {
pool.Close()
}
if err != nil {
logger.Error("migration failed", "error", err)
os.Exit(1)
}
logger.Info("database migrations complete")
}