Documentation
¶
Overview ¶
Package database provides PostgreSQL database client and migration utilities.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateGINIndexes ¶
CreateGINIndexes creates full-text search GIN indexes for PostgreSQL. These indexes enable efficient full-text search on alert_data, final_analysis, and timeline_events content fields.
func CreatePartialUniqueIndexes ¶
CreatePartialUniqueIndexes creates PostgreSQL partial unique indexes that Ent/Atlas cannot express. These must match the constraints in 20260225235224_add_orchestrator_sub_agent_fields.up.sql.
Types ¶
type Client ¶
Client wraps Ent client and provides access to the underlying database
func NewClientFromEnt ¶
NewClientFromEnt wraps an existing Ent client (useful for testing)
type Config ¶
type Config struct {
Host string
Port int
User string
Password string
Database string
SSLMode string
// Connection pool settings
MaxOpenConns int
MaxIdleConns int
ConnMaxLifetime time.Duration
ConnMaxIdleTime time.Duration
}
Config holds database configuration
func LoadConfigFromEnv ¶
LoadConfigFromEnv loads database configuration from environment variables with validation and production-ready defaults
type HealthStatus ¶
type HealthStatus struct {
Status string `json:"status"`
ResponseTime int64 `json:"response_time_ms"`
OpenConnections int `json:"open_connections"`
InUse int `json:"in_use"`
Idle int `json:"idle"`
WaitCount int64 `json:"wait_count"`
WaitDuration int64 `json:"wait_duration_ms"`
MaxOpenConns int `json:"max_open_conns"`
}
HealthStatus represents database health and connection pool statistics