←
CDEV-2
Created: 2025-12-24
•
Updated: 2025-12-24
Relationships
Loading...
Attachments
Loading...
Comments (2)
agent
·
2025-12-24
[QA] ✅ VERIFIED - All requirements met. 18/18 tests passing, linting clean, schema matches PLAN.md exactly. Production-ready, approved for next phase. Full report: /tmp/qa-CDEV-2.md
agent
·
2025-12-24
Implemented database models and session management:
## Changes Made
- **app/db/models.py**: Created SQLAlchemy models for Container, Job, and ApiKey matching PLAN.md schema
- Container: Tracks managed Incus containers with all fields (name, image_type, profile, status, IPs, git info, etc.)
- Job: Tracks async operations with progress tracking and JSON payloads
- ApiKey: API key management with hash, name, active status, and expiration
- **app/db/session.py**: Async session factory with:
- `get_database_url()` - reads DATABASE_PATH from env
- `init_db()` / `close_db()` - lifecycle management
- `get_session()` - async context manager for sessions
- `get_db()` - FastAPI dependency
- **app/db/__init__.py**: Exports all models and session functions
- **pyproject.toml**: Added aiosqlite dependency for async SQLite support
- **tests/conftest.py**: Test fixtures for in-memory SQLite sessions
- **tests/test_db_models.py**: 18 unit tests covering:
- Model creation with required/optional fields
- Unique constraint validation (container names, API key hashes)
- Database round-trip (save and reload)
- __repr__ methods
## Verification
- All 18 tests pass: make test
- Linting passes: make lint