feat(ws server): added in a websocket on port system to help with better logging

This commit is contained in:
2025-07-25 12:13:19 -05:00
parent 074032f20d
commit 5bcbdaf3d0
17 changed files with 679 additions and 19 deletions

View File

@@ -10,6 +10,8 @@ import (
var DB *gorm.DB
type JSONB map[string]interface{}
func InitDB() error {
dsn := fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s",
os.Getenv("DB_HOST"),
@@ -25,8 +27,17 @@ func InitDB() error {
return fmt.Errorf("failed to connect to database: %v", err)
}
// Auto-migrate all models
DB.AutoMigrate(&Log{}) // Add other models here
fmt.Println("✅ Connected to database")
// ensures we have the uuid stuff setup properly
DB.Exec(`CREATE EXTENSION IF NOT EXISTS "uuid-ossp"`)
err = DB.AutoMigrate(&Log{}, &Config{}, &ClientRecord{})
if err != nil {
return fmt.Errorf("failed to auto-migrate models: %v", err)
}
fmt.Println("✅ Database migration completed successfully")
return nil
}