ea6c466c6c
- 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)
1.2 KiB
1.2 KiB
Why
The application currently fails to start when database tables are missing or migrations haven't been applied. This creates a poor deployment experience and requires manual intervention. We need automatic database initialization, migration management, and seed data handling to ensure the application starts reliably in any environment.
What Changes
- Auto-run migrations on startup instead of requiring manual
alembic upgrade head - Improve startup error handling with clear error messages when DB is unavailable
- Add database readiness checks before attempting migrations or seeding
- Seed data management with proper handling of missing tables
- Better database initialization in Docker environments
Capabilities
New Capabilities
database-initialization: Automatic database setup including migrations and seed data
Modified Capabilities
docker-infrastructure: Add database initialization scripts and health checks
Impact
apps/api/src/main.py: Add startup database initializationapps/api/src/database.py: Add connection health checksapps/api/Dockerfile: Add init scriptsdocker-compose.ymlanddocker-compose.traefik.yml: Update startup behavior