canopy-wic Data Model
On this page
Cross-link: canopy-wic API Reference · Source: migrations/
Tables
| Table | Purpose |
|---|---|
|
Per-person WIC enrollment row. One row per (person, certification period). |
|
Signed eligibility determinations per applicant. Carries the four WIC gates ( |
|
Immutable determination input snapshots (T2-4). One row per participant determination (PK = FK |
|
Per-value DEK store for crypto-shred redaction. One row per per-determination DEK: |
|
Required nutritional risk assessment per 7 CFR 246.7(e). One row per assessment with the four 800-series risk-category booleans: |
|
Certification appointment scheduling. One row per scheduled appointment. Carries |
|
Per-service transactional outbox (ADR-018), schema single-sourced in |
|
Per-service consumer inbox (#433 / ADR-018 amendment). |
Cross-service FKs (ADR-001 boundary)
Per ADR-001, canopy-wic holds no Postgres-level foreign keys to other services. The cross-service identifiers it stores are:
-
wic_participants.person_id→ canopy-persons (application-level) -
wic_determinations.application_id→ canopy-applications,household_id+person_id→ canopy-persons (application-level) -
wic_nutritional_risk_assessments.person_id→ canopy-persons,assessor_worker_id→ identity-provider claims (application-level) -
wic_appointments.household_id→ canopy-persons;certification_idis application-level and intentionally nullable (a fresh applicant may not yet have awic_participantsrow)
The one intra-database FK is determination_snapshots.determination_id → wic_determinations(id). Cross-service consistency is the orchestrator’s responsibility, not the program DB’s.
Retention
7 CFR 246.25 governs WIC record retention: at least 3 years from the end of the federal fiscal year in which the records were created (longer if any audit, claim, investigation, or other action involving the records is open). canopy-wic does not handle FTI; no Pub 1075 retention floor applies. Operationally, wic_determinations and wic_participants are retained indefinitely in the production system to support transfer-of-certification (VOC) lookups, with archive moves operator-driven.
Indexes
-
idx_wic_participants_person— per-person enrollment lookup (VOC, recertification) -
idx_wic_participants_status— active-roster listing -
idx_wic_participants_category— per-category reporting -
idx_wic_participants_cert_end— expiring-certification scan for the renewal scheduler -
idx_wic_determinations_application— per-application lookup -
idx_wic_determinations_household— per-household lookup -
idx_wic_determinations_person— per-person lookup -
idx_wic_determinations_status— list endpoint filter -
idx_determination_snapshots_as_of— input-snapshot lookup by evaluation date (ADR-028) -
idx_wic_assessments_person— per-person assessment history -
idx_wic_assessments_date— chronological assessment listing -
idx_wic_appointments_household— per-household upcoming-appointment listing -
idx_wic_appointments_upcoming(partial,WHERE status = 'scheduled') — upcoming-appointments dashboard query -
event_outbox_*— the three generated partial outbox indexes (drainer hot path, lease-aware claim, ADR-039 held-skip); documented once in the data-models index -
event_inbox_unprocessed_idx(partial,WHERE processed_at IS NULL) — replay / janitor hot path
Migration files
-
20260413000000_create_wic_tables.sql— original schema (wic_participants, wic_determinations, wic_nutritional_risk_assessments) with per-FK indexes -
20260508000000_create_event_outbox.sql+20260518004851_event_outbox_lease_columns.sql+20260713000000_event_outbox_hold.sql— the generated ADR-039 single-sourced outbox migrations (cargo xtask outbox-migrations --write); documented once in the data-models index -
20260512000000_create_wic_appointments.sql— #448 certification appointment table for the worker-portalschedule_certification_appointment_wicaction (#392); per-household and upcoming-only partial indexes -
20260516000000_create_event_inbox.sql— #433 consumer-side inbox (ADR-018 amendment) -
20260622000000_create_determination_snapshots.sql—wic_determinations.snapshot_hashcolumn + the immutabledetermination_snapshotstable + its append-only trigger (T2-4 #685; ADR-028) -
20260624140000_create_redaction_keys.sql— the per-serviceredaction_keystable + its one-way-tombstone trigger (T2-6 #687, ADR-036)
All migrations are forward-only per ADR-016.