feat: Add household support (CRUD, associations, impact analysis) #77
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #74
Fixes #75
Fixes #76
Fixes #78
Warning
This PR is still under construction. Additional work may be needed before it's ready for review.
Important
The
policyengine-app-v2repo will also need changes to consume the modifications from this PR. Frontend work should be coordinated once this API is merged.Important
Production database migration required. This PR switches from Supabase SQL migrations to Alembic. After merging, run
alembic stamp a17ac554f4aaon the production database to mark existing schema as migrated. See.claude/skills/database-migrations.mdfor details.Summary
This PR adds comprehensive household support to the API v2 alpha and migrates to Alembic for database migrations.
1. Stored Household CRUD (#74)
Householdmodel withhousehold_dataJSONB storagePOST/GET/DELETE /householdsendpoints2. User-Household Associations (#75)
UserHouseholdAssociationmodel linking users to householdsPOST/GET/PUT/DELETE /user-household-associationsendpoints3. Household Impact Analysis (#76)
Simulationmodel withSimulationTypeenum,household_id,household_resultReportmodel withreport_typefieldPOST/GET /analysis/household-impactendpoints4. Alembic Migration System (#78)
SQLModel.metadata.create_all()with Alembic migrations.claude/skills/database-migrations.mdDatabase Migrations
Now managed by Alembic in
alembic/versions/:d6e30d3b834d_initial_schema.py- Creates all 21 tablesa17ac554f4aa_add_parameter_values_indexes.py- Adds performance indexesFiles Changed
New Files
src/policyengine_api/models/household.pysrc/policyengine_api/models/user_household_association.pysrc/policyengine_api/api/households.pysrc/policyengine_api/api/user_household_associations.pyalembic/- Alembic configuration and migrations.claude/skills/database-migrations.md- Migration guidelinesscripts/seed_nevada.py- Nevada dataset seeding scripttest_fixtures/fixtures_households.pytest_fixtures/fixtures_user_household_associations.pytest_fixtures/fixtures_analysis.pytests/test_households.pytests/test_user_household_associations.pytests/test_analysis_household_impact.pyModified Files
src/policyengine_api/models/simulation.py- Added SimulationType, household_id, household_resultsrc/policyengine_api/models/report.py- Added report_typesrc/policyengine_api/models/__init__.py- Exports new modelssrc/policyengine_api/api/__init__.py- Registers new routerssrc/policyengine_api/api/analysis.py- Added household-impact endpointssrc/policyengine_api/config/settings.py- Fixed database URL portscripts/init.py- Now uses Alembic instead of create_all()CLAUDE.md- Added Alembic documentation referenceTest Plan
alembic stampon production after merge🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com