Quickstart: Checklist Data Layer
Implementation Steps
- Create Models: Add the new model files to
backend/packages/db/db/models/:users.pyunique_targets.pyuser_scans.pyscan_results.py
- Export Models: Update
backend/packages/db/db/models/__init__.pyto export the new models. - Alembic Migration:bash
task backend:migration -- "add checklist models" - Apply Migration:bash
task backend:migrate
Local Development Verification
- Start Services:
task dev(ensure PostgreSQL is running). - Run Tests:bash
uv run pytest backend/packages/db/tests/test_models.py
Key Code Snippets
Unique Hashing (unique_targets.py)
python
import hashlib
def calculate_hash(provider_id: int, campground_id: str, start_date: date, end_date: date) -> str:
hash_input = f"{provider_id}:{campground_id}:{start_date.isoformat()}:{end_date.isoformat()}"
return hashlib.sha256(hash_input.encode()).hexdigest()