feat: add automatic database initialization and recovery

- Add init_database() with alembic programmatic API and retry logic
- Add connection retry with exponential backoff (5 attempts)
- Improve error messages for connection/auth failures
- Add table existence check before seeding data
- Update startup event to run migrations before seeding
- Add wait-for-db.sh script for Docker containers
- Update Docker and docker-compose configurations

Quality gates: ruff ✓, mypy ✓, unit tests (8 passed)
This commit is contained in:
Fusion
2026-05-18 22:09:52 +02:00
parent 29c3563148
commit ea6c466c6c
11 changed files with 338 additions and 22 deletions
+2
View File
@@ -50,6 +50,8 @@ services:
container_name: hq-api
environment:
DATABASE_URL: postgresql+asyncpg://${POSTGRES_USER:-headquarter}:${POSTGRES_PASSWORD:-headquarter}@postgres:5432/${POSTGRES_DB:-headquarter}
POSTGRES_HOST: postgres
POSTGRES_PORT: 5432
REDIS_URL: redis://redis:6379/0
JWT_SECRET: ${JWT_SECRET:-change-me-in-production}
REPO_BASE_PATH: /data/repos