# Codex Pass 02 — Database and Models ## Goal Add SQLAlchemy/Alembic/PostGIS-ready database foundation. ## Must implement - database session management; - base model conventions; - models for Project, Area, Dataset, AnalysisRun, Metric, Export, Job; - migration scaffold; - geometry field strategy documented in code comments or docs; - indexes for FK and future geometry operations; - tests for model imports. ## Must preserve - PostGIS as spatial database; - additive migration approach; - UUID or chosen ID strategy consistently. ## Must not implement - destructive migrations; - live GRB/OSM fetch; - AI tables beyond V1 scaffold unless already specified. ## Output Use `docs/M6_FINAL_HANDOFF_TEMPLATE.md`.