feat: integrate schema initialization into server startup (Phase 3)
- Add schema initialization call after database connection - Initialize schema before handler creation - Fatal on failure (schema is critical for app to function) - Clear log messages show initialization progress Server startup flow: 1. Load config 2. Connect to database 3. Initialize schema (NEW - ensures all tables/functions exist) 4. Create handlers and services 5. Start server
This commit is contained in:
@@ -78,6 +78,14 @@ func main() {
|
|||||||
|
|
||||||
queries := database.New(dbPool)
|
queries := database.New(dbPool)
|
||||||
|
|
||||||
|
// Initialize database schema
|
||||||
|
log.Println("🔧 Ensuring database schema is initialized...")
|
||||||
|
ctx := context.Background()
|
||||||
|
if err := database.Initialize(ctx, dbPool); err != nil {
|
||||||
|
log.Fatal("❌ Database schema initialization failed:", err)
|
||||||
|
}
|
||||||
|
log.Println("✅ Database schema initialized and verified, starting server...")
|
||||||
|
|
||||||
// Create login attempt tracker: 5 failed attempts = 15 minute lockout
|
// Create login attempt tracker: 5 failed attempts = 15 minute lockout
|
||||||
loginAttemptTracker := ratelimit.NewLoginAttemptTracker(5, 15*time.Minute, 5*time.Minute)
|
loginAttemptTracker := ratelimit.NewLoginAttemptTracker(5, 15*time.Minute, 5*time.Minute)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user