canopy-enrollment Data Model
Cross-link: canopy-enrollment API Reference · Source: migrations/
Tables
| Table | Purpose |
|---|---|
|
One row per SNAP household enrollment created off an approved determination. |
|
Per-month issuance ledger. No two live REGULAR rows of one household cover the same month, whichever enrollments hold them ( |
|
THE adverse action: its id IS the |
|
Versioned notice records — the action’s CURRENT legal dates are the operative dispatched version’s (all legal fields are jurisdiction-timezone DATEs); a repair is a SUCCESSOR version with new dates, never an UPDATE. |
|
One row per (action, appeal) with MONOTONIC transitions enforced by the store’s guarded upsert: |
|
Append-only receipt ledger for the action (a DB trigger rejects UPDATE/DELETE) — what arrived, when, from where; consumers derive state from links/status, signals are the audit receipts. |
|
The generated ADR-018 / ADR-039 outbox and the generated consumer inbox (parked-state columns included), single-sourced in |
|
The fleet-wide idempotent-POST cache (#434 / #1463), created outside this service’s |
|
Per- |
|
Append-only reopen receipts for the NARROW Chart 3730.1 periodic-report reopen: one row per reopened ENACTED |
|
ONE row per continuing determination received for a live enrollment — the apply-once ledger ( |
|
ONE row per renewal application ( |
|
The last EBT account activity canopy-enrollment has learned of, one row per processor account ( |
|
Wall-clock window fence for the service’s daily scheduler ticks ( |
Relationships
Intra-database foreign keys only (relationship-only; columns live in the Tables list):
periodic_report_completions has no FK: its (certification_id, generation) key belongs to canopy-renewals (migration 20260729000000_periodic_report_completion_tombstones.sql).
Cross-service FKs (ADR-001 boundary)
Per ADR-001, canopy-enrollment holds no Postgres-level foreign keys to other services. Every UUID outside the intra-database FKs above is an application-level reference canopy-enrollment trusts the upstream (the canopy-eligibility orchestrator, canopy-snap, canopy-renewals, canopy-notices and canopy-appeals) to supply and never enforces in canopy_enrollment: household_id and head_of_household_person_id (canopy-persons), determination_id / previous_determination_id (canopy-snap), application_id / upstream_application_id (canopy-applications), operation_id and postponement_episode_id (canopy-eligibility / canopy-applications), certification_id (canopy-renewals), notice_id (canopy-notices), appeal_id (canopy-appeals) and the recipient snapshot on the adverse action.
Retention
Retention floors (eCFR, checked 2026-09-16): SNAP program records are kept no less than 3 years from the month of origin of each record (7 CFR 272.1(f)), and issuance, reconciliation and accountability records inherit that period through 7 CFR 274.5 — snap_benefit_issuances is the authoritative ledger for that window. State series: Georgia Archives, DHS retention schedule (agency 144), series 1976-0115 "Food Stamp Issuance Files", 3 years, and series 1976-0112 "Food Stamp/Coupon Accountability Report Files", 5 years — https://www.georgiaarchives.org/records/agencyprint/144 (checked 2026-09-18). The issuance series does not exceed the federal 3-year floor, so 7 CFR 272.1(f) / 274.5 governs snap_benefit_issuances; the accountability-report series is longer than the federal floor, so the state series governs the reconciliation and accountability reports filed under it. Rows are not deleted in production; archive moves are operator-driven, never migration-driven (ADR-016). partial_retention + retained_through on snap_enrollments drive PAMMS 2415 mid-month closure semantics (#407) so downstream overpayment math can distinguish retained from recoverable months without re-deriving from the issuance ledger.
Indexes
-
idx_snap_enrollments_household— household-scoped enrollment lookup -
idx_snap_enrollments_status(partial,WHERE status='pending_issuance') — issuance-pipeline due-queue -
snap_enrollments_one_live_per_household(partial UNIQUE,WHERE active AND status IN ('pending_issuance','active','suspended')) — #1130: the one-live-enrollment-per-household invariant, structural (the reopen successor gate and the create paths are check-then-act without it) -
idx_snap_enrollments_expiry_scan(partial,(certification_end_date, id) WHERE active AND status IN ('pending_issuance','active','suspended')) — #1661: the certification-expiry sweep’s keyset scan; its predicate is byte-identical to the one-live fence’s so the scan and the fence agree on who is live (EXPLAIN-pinned) -
idx_snap_enrollments_ebt_account(partial,WHERE ebt_account_id IS NOT NULL) — #3076: the EBT activity consumer finds an account’s enrollments by index, never by scanning them all -
idx_snap_issuances_enrollment_month— partial UNIQUE(enrollment_id, benefit_month) WHERE issuance_kind = 'regular' AND issuance_status <> 'cancelled'— one live REGULAR issuance row per (enrollment, benefit_month); #1659 narrowed it under its ORIGINAL name (the 409benefit_month_already_issuedmapping keys on the name) so a supplemental row for an issued month is the one legal second row -
idx_snap_issuances_enrollment_month_all— plain(enrollment_id, benefit_month)over ALL rows (#1659): the kind-agnostic readers (QC batchGet, the annual recap, appeals, snap sizing) ride this now that the UNIQUE is partial (EXPLAIN-pinned) -
idx_snap_issuances_supplemental_of(partial UNIQUE,WHERE supplemental_of_continuation_id IS NOT NULL) — #1659: exactly one supplement per continuation -
idx_enrollment_continuations_enrollment—(enrollment_id, determined_at DESC, id DESC)(#1659): the newest-first history read and the lineage probe (the newest open row by the causal clock, id as the tie-break) -
idx_enrollment_continuations_open_action(partial,(adverse_action_id) WHERE status IN ('staged','partially_applied')) — #1659: the enact-sweep join from a staged action to its still-open continuation row -
idx_snap_issuances_expiry(partial,WHERE expunged_at IS NULL AND issuance_status='issued') — expungement-sweeper hot path -
snap_benefit_issuances_pending_settle_idx(partial,(created_at) WHERE issuance_status = 'pending') — the settler’s pending-row scan (migration20260802000000) -
idx_pending_terminations_enrollment— actions by enrollment;idx_pending_terminations_household_open(partial,WHERE status = 'scheduled') — the household’s open action (#1095) -
idx_one_open_action_per_enrollment(UNIQUE partial,(enrollment_id) WHERE status = 'scheduled') — one open action per enrollment (#1096) -
idx_pending_terminations_due_scheduled(partial,(enact_not_before, id) WHERE status = 'scheduled') — the #1220 enact-sweep claim predicate -
idx_action_notices_action(adverse_action_id, version DESC)— the current-version read;idx_action_notice_evidence(UNIQUE partial,(adverse_action_id, notice_id) WHERE notice_id IS NOT NULL) — order-independent notice-evidence upserts (#1101) -
idx_appeal_links_appeal— links by appeal;idx_action_signals_action(adverse_action_id, recorded_at)— the receipt ledger read (#1095) -
idx_enrollment_reopens_enrollment— reopen receipts by enrollment (#1108) -
generated
event_outbox_*/event_inbox_*indexes — described once in the data-models index
Migration files
The eight event_outbox / event_inbox files (20260508000000, 20260516000000, 20260518004851, 20260713000000, 20260720000000, 20260803000000, 20260815000000, 20260904000000) are generated copies of crates/canopy-mq/outbox-migrations/ (cargo xtask outbox-migrations --write, parity-gated by --check); they are described once in the data-models index. The remaining files, in timestamp order:
-
20260401000000_create_enrollment_tables.sql— original schema (snap_enrollments, snap_benefit_issuances; status / type / amount CHECK constraints; lifecycle + expungement indexes) -
20260511000000_add_partial_retention_to_snap_enrollments.sql— #407 / PAMMS 2415 mid-month closure columns (partial_retention,retained_through) -
20260723000000_adverse_action_entity.sql— #1095 adverse-action entity (the four tables above +snap_enrollments.lifecycle_revision+ the first-of-monthbenefit_monthCHECK) -
20260723180000_monthly_issuance_amount.sql— #993: renamessnap_enrollments.max_monthly_allotmenttomonthly_issuance_amount(the household’s net monthly benefit; the old name claimed a gross cap the service never enforced) -
20260724000000_head_of_household.sql— #1096:snap_enrollments.head_of_household_person_id(the legal-recipient snapshot source) + the one-open-action-per-enrollment partial unique (idx_one_open_action_per_enrollment) -
20260728000000_notice_evidence_binding.sql— #1101: partial UNIQUE(adverse_action_id, notice_id)making the notice.generated/notice.dispatched evidence upserts order-independent -
20260729000000_periodic_report_completion_tombstones.sql— #1107:periodic_report_completionstombstone table, PK(certification_id, generation) -
20260730000000_enrollment_reopens.sql— #1108: theenrollment_reopensappend-only reopen receipts,UNIQUE(adverse_action_id) -
20260801000000_one_live_enrollment_per_household.sql— #1130: deterministic duplicate resolution (keep earliest live per household, deactivate + revision-bump the rest) + thesnap_enrollments_one_live_per_householdpartial unique -
20260802000000_pending_issuance_settlement_index.sql—snap_benefit_issuances_pending_settle_idx, partial(created_at) WHERE issuance_status = 'pending', for the settler’s scan -
20260809000000_reason_display_text.sql— #1120:enrollment_pending_terminations.reason_display_text(backfilled, thenSET NOT NULL) — the household-facing reason line snapshotted at schedule time -
20260821000000_restayed_link_state.sql— #1263:restayedjoins thetermination_appeal_linksstatus CHECK (stayed/restayed/released/vetoed) — the final-appeal stay era -
20260829000000_enact_sweep_claims.sql— #1220: thesweep_claimed_at/sweep_claimed_bylease pair onenrollment_pending_terminations+idx_pending_terminations_due_scheduled -
20260905000000_create_scheduler_runs.sql— the generated #1211 window-fence table (single-sourced incrates/canopy-db/scheduler-migrations/); documented once in the data-models index -
20261209000000_uprov_b_enrollment_provenance.sql— #788: theeffective_date_basis+benefit_effective_dateprovenance pair onsnap_enrollments -
20261221000000_expiry_sweep_and_combined_allotment.sql— #1661:snap_enrollments.expired_at; theidx_snap_enrollments_expiry_scanpartial index;snap_benefit_issuances.combined+benefit_months_coveredwith the range + pair CHECKs; theissuance_statusCHECK widened withcancelled(DROP+ADD). Transactional, NOT CONCURRENTLY (#1196). -
20261222000000_issuance_covered_next_month.sql— #1692:covered_next_month_amount+ its pair/bounds CHECKs,btree_gist, and thesnap_issuances_no_overlapping_coverageEXCLUDE belt (transactional, NOT CONCURRENTLY). -
20261225000000_continuations_and_issuance_kind.sql— #1659: theenrollment_continuationsledger + its two indexes;snap_enrollments.determined_at;snap_benefit_issuances.issuance_kind(7 CFR 274.1(h)(4)) +supplemental_of_continuation_idwith the pair CHECK and partial UNIQUE; the month UNIQUE DROPped and re-created UNDER THE SAME NAME as a partial over live regular rows, the plainidx_snap_issuances_enrollment_month_all, and the coverage EXCLUDE re-created for regular rows only;enrollment_pending_terminations.proposed_benefit_amount+target_certification_end_datewith their CHECKs (legacy amount-less scheduled reductions cancelled first). Forward-only, transactional, NOT CONCURRENTLY (#1196). -
20261231000000_issuance_settle_claim.sql— #1635:snap_benefit_issuances.settle_claimed_at(TIMESTAMPTZ, nullable) — the settle claim lease stamped before the EBT call and cleared by the landing mark; a pending row under a lease younger than ten minutes is never cancelled by the expiry sweep. Additive, transactional, NOT CONCURRENTLY (#1196). -
20270101000000_enrollment_benefit_month_prices.sql— #1704:snap_enrollments.benefit_month_prices(JSONB, nullable) + thesnap_enrollments_benefit_month_prices_is_arrayCHECK (NOT VALID — existing rows are all NULL). Additive, transactional, NOT CONCURRENTLY (#1196). -
20270102000000_issuance_ebt_accepted_on.sql— #1743:snap_benefit_issuances.ebt_accepted_on(DATE, nullable) — the acceptance-day anchor stamped by both arms of the fence re-assert, from which a later landing dates the expungement clock and the first-issuance activation (7 CFR 274.2(i)(1)(ii)). Additive, transactional, NOT CONCURRENTLY (#1196). -
20270103000000_certification_window_check.sql— #2031: thesnap_enrollments_certification_window_checkCHECK (certification_end_date >= certification_start_date), VALIDATED — rewrites nothing and fails loudly on an inverted row (reseed first — devstack-only data, ADR-016; none existed on 2026-09-15). Transactional, NOT CONCURRENTLY (#1196). -
20270104000000_issuance_status_drop_reversed.sql— #2128:snap_issuances_status_checkDROP+ADDed under its own name withoutreversed(pending/issued/failed/cancelled;failedreserved for #1553; the migration’s own comments cite #1112, the notice carriers, in error), VALIDATED — no writer ever produced areversedrow, so it rewrites nothing and fails loudly if one exists (reseed first — devstack-only data, ADR-016). Transactional, NOT CONCURRENTLY (#1196). -
20270105000000_continuation_certification_category.sql— #1703:enrollment_continuations.certification_category(TEXT, nullable) with its four-token CHECK (standard/elderly_disabled/senior/abawd; replaced by the #2209 migration below). Plain ADD COLUMN — no default, no rewrite, no backfill (no pre-#1703 production history). Transactional, NOT CONCURRENTLY (#1196). -
20270106000000_continuation_basis_kinds.sql— the re-determination basis kinds:enrollment_continuations.basis_kindCHECK re-declared under the same name overCONTINUATION_CLASS_KINDS(in_cert_conversion/interim_change/order_continuation); the episode-presence CHECK unchanged. -
*_continuation_category_pack_owned.sql— #2209:DROP CONSTRAINT enrollment_continuations_certification_category_check(the four-token list), replaced byCHECK (length(certification_category) BETWEEN 1 AND 64)and a column COMMENT naming[[snap.certification.categories]]as the authority — a CHECK never pins a pack vocabulary (the neutrality rule); the CHECK-equals-Rust test no longer asserts this column. Forward-only, no rewrite, no backfill; transactional, NOT CONCURRENTLY (#1196). -
20270107000000_continuation_basis_kinds_cola.sql— #806:enrollment_continuations.basis_kindCHECK re-declared again under the same name over the FOUR-tokenCONTINUATION_CLASS_KINDS(in_cert_conversion/interim_change/order_continuation/mass_change_cola); the episode-presence CHECK unchanged. -
20270108000000_enrollment_successors.sql— the scheduled successor enrollment: thesnap_enrollment_successorstable (the decision, status and pair CHECKs; the one-scheduled-per-household partial unique; the due and household indexes). -
20270110000000_expungement_notice_dispatch.sql— #2407:snap_benefit_issuances.expungement_notice_event_id(UUID) +expungement_notice_dispatched_on(DATE), thesnap_issuances_expungement_dispatch_needs_event_chkpair CHECK and the partial UNIQUEidx_snap_issuances_expungement_notice_event; clearsexpungement_notice_sent_aton every unexpunged row (no earlier stamp can be correlated to a dispatch, and none before #2388 answered a letter), so the pass notices those rows again, late. Transactional, NOT CONCURRENTLY (#1196). -
20270111000000_action_notice_letter_key.sql— #2459:adverse_action_notices.source_event_id/notice_type(the work-item key a regenerated letter shares with the stale one) andawaiting_regeneration; additive, NULL keys on rows recorded before -
20270216000000_ebt_account_activity.sql— #1744: thesnap_ebt_account_activitytable with itssourceCHECK;observed_athas no default (#2589); the partial indexidx_snap_enrollments_ebt_account. -
20270217002423_expungement_notice_restage.sql— #2423:snap_benefit_issuances.expungement_notice_staged_on(DATE) +expungement_notice_restage_count(INTEGER NOT NULL DEFAULT 0) with thesnap_issuances_expungement_staged_needs_event_chkandsnap_issuances_expungement_restage_count_chkCHECKs; backfills the staging day of every row with an event id fromexpungement_notice_sent_aton the UTC calendar (a migration cannot name the pack’s timezone; at most one day off the legal day). Transactional, NOT CONCURRENTLY (#1196). -
20270402000000_drop_adverse_action_recipient_text.sql— #3386: dropsenrollment_pending_terminations.recipient_nameandrecipient_address, which no writer filled and no reader read. -
20270403000000_household_month_coverage_belt.sql— #1747:snap_issuances_no_household_overlap, the coverage belt over the household: no two liveregularrows of one household cover the same month, whichever enrollments hold them. The migration refuses to run while such pairs exist and says how many; it changes no row, because which of two payments stands is a case decision. To list them first:SELECT a.household_id, a.id, a.enrollment_id, a.benefit_month, b.id, b.enrollment_id, b.benefit_month FROM snap_benefit_issuances a JOIN snap_benefit_issuances b ON a.household_id = b.household_id AND a.id < b.id WHERE a.issuance_status <> 'cancelled' AND a.issuance_kind = 'regular' AND b.issuance_status <> 'cancelled' AND b.issuance_kind = 'regular' AND int4range((EXTRACT(YEAR FROM a.benefit_month) * 12 + EXTRACT(MONTH FROM a.benefit_month))::int, (EXTRACT(YEAR FROM a.benefit_month) * 12 + EXTRACT(MONTH FROM a.benefit_month))::int + a.benefit_months_covered) && int4range((EXTRACT(YEAR FROM b.benefit_month) * 12 + EXTRACT(MONTH FROM b.benefit_month))::int, (EXTRACT(YEAR FROM b.benefit_month) * 12 + EXTRACT(MONTH FROM b.benefit_month))::int + b.benefit_months_covered);
All migrations are forward-only per ADR-016.