Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Config struct {

func LoadConfig() *Config {
return &Config{
DatabaseURL: GetEnv("DATABASE_URL", "postgres://authuser:authpass123@localhost:5400/authdb?sslmode=disable"),
DatabaseURL: GetEnv("DATABASE_URL", "postgres://authuser:authpass123@localhost:5400/authdbui?sslmode=disable"),
JWTSecret: GetEnv("JWT_SECRET", "your-secret-key-here"),
Port: GetEnv("PORT", "5400"),
GinMode: GetEnv("GIN_MODE", "debug"),
Expand Down
12 changes: 3 additions & 9 deletions backend/postgresql/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package postgresql

import (
"fmt"
"os"

"github.com/kubestellar/ui/backend/log"
"github.com/kubestellar/ui/backend/pkg/config"
"go.uber.org/zap"

"github.com/golang-migrate/migrate/v4"
Expand All @@ -13,17 +13,11 @@ import (
)

func RunMigration() error {
dbURL := os.Getenv("DATABASE_URL")
if dbURL == "" {
log.LogError("DATABASE_URL environment variable is not set")
return fmt.Errorf("DATABASE_URL is not set")
}

migratePath := "file://postgresql/migrations"

DBURL := config.LoadConfig().DatabaseURL
m, err := migrate.New(
migratePath,
dbURL,
DBURL,
)
if err != nil {
log.LogError("Failed to initialize migrate", zap.String("error", err.Error()))
Expand Down
2 changes: 1 addition & 1 deletion backend/test/pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestLoadConfigDefaults(t *testing.T) {

cfg := config.LoadConfig()

assert.Equal(t, "postgres://authuser:authpass123@localhost:5400/authdb?sslmode=disable", cfg.DatabaseURL)
assert.Equal(t, "postgres://authuser:authpass123@localhost:5400/authdbui?sslmode=disable", cfg.DatabaseURL)
assert.Equal(t, "your-secret-key-here", cfg.JWTSecret)
assert.Equal(t, "5400", cfg.Port)
assert.Equal(t, "debug", cfg.GinMode)
Expand Down
Loading