2.1 KiB
2.1 KiB
Tasks: Database Models
Task 1: Create project structure and configuration
- Create
apps/api/src/models/__init__.py - Create
apps/api/src/config.pywith pydantic-settings for database URL - Create
apps/api/src/database.pywith async engine and session
Task 2: Create base model
- Create
apps/api/src/models/base.pywith DeclarativeBase - Add UUID primary key mixin
- Add timestamp mixin (created_at, updated_at)
Task 3: Create User model
- Create
apps/api/src/models/user.py - Define User with all fields from spec
- Add relationships to Project, SSHKey, UserConfig
Task 4: Create Project model
- Create
apps/api/src/models/project.py - Define Project with all fields
- Add relationships to User, GitRepository, SSHKey
Task 5: Create GitRepository model
- Create
apps/api/src/models/git_repository.py - Define GitRepository with all fields
- Add relationships to Project, User
Task 6: Create SSHKey model
- Create
apps/api/src/models/ssh_key.py - Define SSHKey with all fields
- Add relationships to User, Project
Task 7: Create UserConfig model
- Create
apps/api/src/models/user_config.py - Define UserConfig with JSONB config field
- Add relationship to User
Task 8: Initialize Alembic
- Create Alembic scaffolding equivalent to
alembic init - Configure
alembic/env.pyfor async - Update
alembic.iniwith correct URL
Task 9: Create initial migration
- Generate migration creating all tables
- Verify migration is correct
Task 10: Create seed script
- Create
apps/api/src/scripts/seed.py - Add test user and sample data payload helper
- Make script runnable
Task 11: Create tests
- Create
apps/api/tests/test_models.py - Test model creation and relationships
- Test async database operations
Task 12: Run quality gates
- Run
pytest- all tests pass - Run
mypy .- no type errors - Run
ruff check .- no lint errors
Runtime Verification
- Run migrations against a live PostgreSQL instance to verify end-to-end database execution.