canopy-enrollment Data Model

Tables

Table Purpose

snap_enrollments

One row per SNAP household enrollment created off an approved determination. application_id is the canopy-applications id (#1870) — the event’s upstream_application_id, emitted on every snap determination since #1662 — never the snap-LOCAL application_id the same wire body carries; it is the only id the row can be joined back to its application by, so an approved determination.completed.snap without the upstream id is refused to the DLQ (the #1014 posture) rather than filed under another service’s id space. Carries the certification_start_date / certification_end_date window, the monthly_issuance_amount (#993 — the household’s NET monthly benefit, issued directly each month with first-month proration; renamed from max_monthly_allotment, whose name claimed a gross cap the service never enforced), the optional ebt_account_id returned by the EBT adapter, the expedited flag (drives 7-day issuance under 7 CFR 273.2(i)), the initial_issuance_due_date (lifecycle SLA) and matching initial_issuance_date on success. Status moves through pending_issuance → active → suspended/terminated/expired; suspended_reason / terminated_reason / terminated_date are populated on the exit transitions. Per #407 / PAMMS 2415, mid-month closure semantics are surfaced via partial_retention (BOOLEAN) and retained_through (DATE) so downstream overpayment math can distinguish retained vs recoverable months. head_of_household_person_id (#1096, nullable) is the legal-recipient snapshot source for adverse-action scheduling — populated at creation since #1096 and REQUIRED by the schedule API (422 while NULL). lifecycle_revision (#1095) is the shared lifecycle fence: every lifecycle transition (termination via the #1102 guarded enact primitive — sweep, on-demand trigger, or appeal-resolution consumer) bumps it, and the post-EBT issuance mark is preconditioned on the value read BEFORE the EBT call — a termination landing mid-issuance kills the late mark instead of resurrecting the closed case. One live enrollment per household is structural (#1130): the snap_enrollments_one_live_per_household partial unique (WHERE active AND status IN pending_issuance/active/suspended) is the fence every code path answers to — a duplicate INSERT (a NON-continuation approving re-determination from the determination subscriber, PARKED — the #1089 disposition, first wired ParkEvent caller — until the prior row leaves the live set; it is the defect fence only, since every re-determination of a live household now applies in place through the continuation arm (interim_change, order_continuation, mass_change_cola) or schedules a successor (recert_approval); the create API, 409) and the #1108 reopen’s un-terminate racing a re-application (typed raced refusal) all converge on it; its migration deterministically resolved pre-fence duplicates (keep the earliest-created live row, deactivate + revision-bump the rest so the issuance fence kills their in-flight marks — the replay test re-executes the marked SQL and drives the fence). Since #788 the row also persists the event-carried effective-date provenance pair — effective_date_basis (JSONB {"kind": …}, the signed union canopy_types::effective_date_basis::EffectiveDateBasis: determination_day, order_effective, mass_change_cola, agency_fault_pending, application_reopen, expedited_postponed, in_cert_conversion, recert_reinstatement, interim_change, order_continuation and recert_approval — tolerated since #1661, emitted since #1662) + benefit_effective_date — written by auto_enroll when determination.completed.snap carries them (use-when-present through the tolerant window; NULL = enrolled from a pre-provenance event, never backfilled; migration 20261209000000_uprov_b_enrollment_provenance.sql). Since #1704 the row also persists benefit_month_prices (JSONB, nullable; CHECK jsonb_typeof = 'array') — the determination’s signed per-benefit-month price schedule ([{benefit_month, allotment, params_digest}], ascending, first entry the initial month), which the issuance path uses as each benefit month’s BASE figure so a back-pay month keeps the figure of the window in force IN it; NULL = an HTTP-created or pre-#1704 row, which prices every month at monthly_issuance_amount as before (nothing backfilled; migration 20270101000000_enrollment_benefit_month_prices.sql). Expiry (#1661): the certification-expiry sweep is the second lifecycle writer beside the guarded enact primitive — once the INCLUSIVE certification_end_date has passed (legal today > end) it flips a live row to expired in ONE UPDATE that also bumps lifecycle_revision and stamps expired_at (TIMESTAMPTZ, the pass’s decision instant; DB-only, off the wire); the re-checked predicate is the stamp fence, so a second pass or a concurrent replica matches nothing. The same transaction stages the pinned enrollment.expired event after the action moots (#1691 — ids, the inclusive end, the pass instant, the post-flip revision and the row’s cancellation tallies; audit-only: canopy-security + the worker portal), so the event exists iff the flip commits, at most once per row by that fence. The flip releases the one-live fence, so a parked duplicate approval lands. Continuation (#1659): a continuation-class determination for an already-enrolled household (effective_date_basis.kind ∈ CONTINUATION_CLASS_KINDS, first member in_cert_conversion) applies IN PLACE — monthly_issuance_amount, certification_end_date and — since #1704 — benefit_month_prices are rewritten by ONE UPDATE under the full live predicate plus the lifecycle_revision fence (bumped), never a second live row and never a park; the price schedule is REPLACED by the continuing determination’s own and set NULL when it carries none (a noticed reduction always sets NULL), so the superseded certification’s per-month figures can never outrank the amount that replaced them; reductions, shortenings and continuation-class denials wait on an adverse action (below) and rewrite at enactment. determined_at (TIMESTAMPTZ, nullable; migration 20261225000000) is the certifying determination’s signed instant, stamped at auto-enroll and re-stamped by every applied continuation — the enrollment’s causal clock for canopy_types::causal::supersedes (an older or equal arrival is recorded superseded and applies nothing; a pre-#1659 row’s NULL falls back to created_at). DB-only, off the wire. Certification window (#2031): snap_enrollments_certification_window_check — CHECK (certification_end_date >= certification_start_date), VALIDATED (not NOT VALID: Postgres enforces a NOT VALID CHECK on every later UPDATE of an old row, so a tolerated inverted row would fail the expiry sweep’s flip on every pass); the HTTP create refuses the pair first (422 certification_end_before_start) and the event path has ordered its signed period since #1487 — the CHECK is the belt beneath both (migration 20270103000000_certification_window_check.sql).

snap_benefit_issuances

Per-month issuance ledger. No two live REGULAR rows of one household cover the same month, whichever enrollments hold them (snap_issuances_no_household_overlap, #1747). One REGULAR row per (enrollment, benefit_month) — enforced by idx_snap_issuances_enrollment_month, since #1659 a partial UNIQUE WHERE issuance_kind = 'regular' AND issuance_status <> 'cancelled' re-created UNDER ITS ORIGINAL NAME (the HTTP issue path maps that name’s 23505 to the 409 benefit_month_already_issued; a rename would surface as a 500). Captures the allotment_amount, the proration triplet (prorated, proration_days_remaining, proration_days_total) used for the first cert month under 7 CFR 273.10(a), the EBT-adapter ebt_transaction_id + issued_at, the issuance_status (CHECK pending / issued / failed / cancelled — the set 20261221000000_expiry_sweep_and_combined_allotment.sql widened with cancelled and 20270104000000_issuance_status_drop_reversed.sql narrowed by dropping reversed (#2128: no writer, no owner, no reversal path in the service); the store writes pending, issued and cancelled; failed is reserved (#1553) for the real-adapter settler, its writer-to-be; cancelled (#1661) is terminal for a pending row whose enrollment expired before settlement and no adapter ever touched — a settler whose fenced mark lost after EBT accepted the transfer re-asserts pending) and issuance_error on failure (the sweep writes the discriminating texts: an entitled month "restoration candidate (7 CFR 273.17; #1661)" vs "benefit month after certification end (#1661)"), the first-of-month benefit_month CHECK (#1095; NOT VALID for pre-existing devstack seeds — a benefit month is a MONTH), the expiry_date — the expungement clock (7 CFR 274.2(i)(2); [snap.issuance].expungement_days after the ISSUANCE day): since #1635 every writer anchors it on the issuance day — the HTTP path and the settler’s landing mark both stamp it from the legal today each read ONCE before its EBT call (benefit_expiry_date(params, today)), the event path’s mint writes only a provisional consume-day value the landing overwrites (the expungement drains find_approaching_expungement / find_expired_issuances read issued rows only); a landing whose fenced mark LOST after the processor accepted the transfer records that pass’s pre-call day in ebt_accepted_on (DATE, nullable; #1743, both fence arms, first acceptance wins) and every later landing derives ONE issuance day from it for the expiry AND the first-issuance activation date, so a retry cannot push the expungement clock forward (7 CFR 274.2(i)(1)(ii)). Which clock it is follows the pack’s snap.issuance.expungement_approach (#1744): under unused_benefits, (i)(1)(ii), it stays the issuance day plus expungement_days; under inactive_account, (i)(1)(i), the ebt.account_activity.observed consumer moves every unexpunged issued row of the account to the activity day plus expungement_days when that is later, clearing the notice columns together and resetting the re-stage count (src/ebt_activity.rs). Then come the expungement triple (expungement_notice_sent_at, expunged_at, expunged_amount). #2407: expungement_notice_event_id (UUID, nullable; the staged enrollment.expungement_pending envelope id, partial UNIQUE idx_snap_issuances_expungement_notice_event) and expungement_notice_dispatched_on (DATE, nullable; the letter’s first dispatch day from notice.dispatched, and never set without the event id — snap_issuances_expungement_dispatch_needs_event_chk) carry the advance-notice precondition: the expunge pass holds a row past expiry until its notice is dispatched and the advance window has run from the dispatch day (API reference, Expungement). #2423: expungement_notice_staged_on (DATE, nullable; the legal day the current notice was staged, from which the re-notice bound [shared.timing].expungement_renotice_after_days runs, never set without the event id — snap_issuances_expungement_staged_needs_event_chk) and expungement_notice_restage_count (INTEGER NOT NULL DEFAULT 0, snap_issuances_expungement_restage_count_chk ≥ 0; how many times the pass re-staged the notice because the one before stayed undispatched past the bound) drive the re-notice of a held row (API reference, Re-notice). #1661: combined (BOOLEAN NOT NULL DEFAULT false) + benefit_months_covered (SMALLINT NOT NULL DEFAULT 1, CHECK 1..2, pair-CHECKed combined = (benefit_months_covered = 2)) mark the 7 CFR 274.2(c) combined initial allotment — the prorated filing month plus the full following month in ONE row keyed on the filing month — minted only by the event path in the enrollment’s own insert transaction; both ride the wire additively. covered_next_month_amount NUMERIC(12,2) (#1692; the month+1 part of a combined row’s amount, NULL iff not combined — snap_issuances_covered_next_pair_check, added NOT VALID so a pre-#1692 combined row (only live-test fixtures; the producer is dormant) keeps NULL and attributes wholly to its own month; bounded 0 ≤ x ≤ allotment_amount); the coverage BELT snap_issuances_no_overlapping_coverage — an EXCLUDE USING gist over (enrollment_id, int4range(month ordinal, month ordinal + benefit_months_covered)) for non-cancelled rows (btree_gist) — refuses any two live REGULAR rows of one enrollment covering the same calendar month beside the (enrollment_id, benefit_month) unique (re-created by 20261225000000 with issuance_kind = 'regular' in its predicate). Issuance kind (#1659, 7 CFR 274.1(h)(4)): issuance_kind TEXT NOT NULL DEFAULT 'regular' CHECK IN ('regular','supplemental','replacement','restored') identifies every row — regular is the ongoing allotment (the prorated first row too, flagged by the proration triplet; every pre-#1659 row and every explicit-column INSERT), supplemental is the ONE legal second row for an already-issued month that an in-place increase mints for new − previous (prorated by the covering row’s own day ratio when that row was the prorated initial month keyed on the effective month; 273.12(c)) — and since #1722 a supplemental row MAY carry the combined shape itself (combined = true, benefit_months_covered = 2, covered_next_month_amount = the month+1 delta, allotment_amount = the two-month total) when the row it supplements is the issued combined initial allotment keyed on the effective month, so covered_months splits the supplement exactly like the row it tops up (the coverage belt ignores supplemental rows, so the shape is legal) — replacement / restored are vocabulary only (no writer). A supplemental row names its continuation in supplemental_of_continuation_id (UUID NULL, FK enrollment_continuations; pair-CHECKed snap_issuances_supplemental_pair_check; exactly once — the partial UNIQUE idx_snap_issuances_supplemental_of) and settles like any pending row; every kind-agnostic aggregate (the annual recap, QC batchGet, appeals CB/overpayment, snap overpayment sizing) sums it as issued money. A still-pending regular row whose amount a continuation superseded is cancelled with issuance_error = 'superseded_by_continuation' and re-minted under a NEW id at the new amount (EBT idempotency is per issuance id) from the effective month on; if a settler had already moved the money for that month when the re-mint committed, the replacement is retired with 'superseded_re_mint_lost_to_in_flight_settlement' and the old row re-asserted pending (paid once, at the old amount; logged at ERROR with reconciliation_required = true). settle_claimed_at (TIMESTAMPTZ, nullable; #1635, migration 20261231000000) is the settle-claim lease stamped before the EBT call (by the settlement pass’s claim, or since #2664 by the manual issue path’s insert of its own row) and cleared by the landing mark; the expiry sweep never cancels a pending row under a lease younger than ten minutes.

enrollment_pending_terminations (#1095)

THE adverse action: its id IS the adverse_action_id carried through notice → appeal → stay/veto → enactment → assessment → claim. Carries the policy snapshot (policy_version, required_advance_days, cb_available, cb_rule, and reason_display_text — #1120: the household-facing reason line, resolved from the [[snap.adverse_action.reasons]] vocabulary’s display_text at schedule time; the letter renders the worker narrative when present, else this snapshot, so a vocabulary edit never rewrites an already-noticed action’s letter: it is immune to later policy edits), provenance + generation idempotency (UNIQUE(created_source, source_reference, source_generation) — a re-fired source upserts, a new generation is a new action), the PAMMS 3705 advance-notice exemption (authority + actor pair-required by CHECK), the recipient’s person id (recipient_person_id; canopy-notices resolves the name and address when it renders), enact_not_before (the current window’s floor, moved by a repair or reschedule; the operative dispatched notice version is the one covering it (#2461); re-read under the enrollment lock at Phase-3 enactment), and status ∈ scheduled/enacted/cancelled/vetoed (stays are NOT a status — they live per-appeal in the links table). The #1220 sweep-lease pair (sweep_claimed_at, sweep_claimed_by) lets enact-sweep passes claim due actions in bounded FOR UPDATE SKIP LOCKED batches so replicas share a month-end spike — a work-sharing hint only, never the enactment authority (the guarded gate re-checks status under the row locks); idx_pending_terminations_due_scheduled serves the claim predicate. Global lock order: snap_enrollments row FIRST, then action rows ORDER BY id (since #1659 the issuance-touching paths take the enrollment’s pending issuance rows FOR UPDATE ORDER BY id BEFORE the enrollment — the lock order the settler shares). #1659: proposed_benefit_amount NUMERIC(10,2) NULL — the noticed NEW allotment a reduction enacts in place (required on a scheduled reduction, refused on a termination: pending_terminations_reduction_amount_check / pending_terminations_termination_no_amount_check) — and target_certification_end_date DATE NULL — the shortened end a continuation-staged reduction enacts (pending_terminations_target_end_check: reductions only; never claimable over HTTP). #3219: action_type admits member_sanction, the person-level work sanction, which carries person_id, sanction_ref, violation_number and minimum_period_ends_on (all present iff action_type = 'member_sanction': pending_terminations_member_sanction_subject_check) and a proposed_benefit_amount when scheduled (pending_terminations_member_sanction_amount_check); migration 20270321000000_member_sanction_actions.sql, which also adds work_sanction to enrollment_continuations.basis_kind. A continuation stages under created_source = 'continuation', source_reference = the enrollment_continuations row id, generation 0; a newer determination cancels a still-scheduled continuation action with reason superseded_by_newer_determination before staging its own; an open action the continuation does not own is a DLQ, never a cancel.

adverse_action_notices (#1095)

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. version is arrival order only, and nothing reads it as recency (#2461): a no-evidence repair can mint a successor while the earlier letter’s events wait in the DLQ, and a resend can re-render an old window’s letter after the repair’s letter was dispatched, so either may carry the higher version. The action’s current legal dates — the enact gate’s evidence and the noticed_date the views serve to appeals — come from the operative dispatched version: one whose noticed_effective_date covers the action’s current floor (enact_not_before), then the latest window, then the highest version. A dispatch supersedes only versions for an earlier window, or lower versions for its own window, never a later window’s. A letter canopy-notices regenerated because its legal day passed (#2447) can arrive in any order against the stale one, which notice.stale retires (#2459). The work-item key — source_event_id + notice_type (UUID / TEXT, nullable; migration 20270111000000), recorded from whichever evidence event carries it — ties a regenerated letter to the stale one; awaiting_regeneration (BOOLEAN NOT NULL DEFAULT false) marks a stale version whose regeneration is coming, which keeps counting as a staged successor until the first non-awaiting version with its key is recorded, or a regenerating = false announcement arrives, and either supersedes it. superseded_at therefore marks a version that is no longer, or never will be, operative; the repair gate’s staged-successor check skips it. UNIQUE(adverse_action_id, version).

termination_appeal_links (#1095)

One row per (action, appeal) with MONOTONIC transitions enforced by the store’s guarded upsert: stayed → released, stayed → vetoed, released → vetoed (a veto is durable and order-independent — it moots the action even post-release); vetoed is terminal. restayed (#1263) is the final-appeal stay era (Chart B3): only the explicit restay command enters it (released|stayed → restayed) and only the appeals-sequenced sync release, a veto, or cancel_action's links-moot (the action is dead either way) ends it — the appeal.decision_recorded convergence replay is fenced out, so a relay-lagged decision event can never release a judicial continuation granted after the decision. An action proceeds only at ZERO active stays; both stay eras count.

action_signals (#1095)

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.

event_outbox, event_inbox

The generated ADR-018 / ADR-039 outbox and the generated consumer inbox (parked-state columns included), single-sourced in crates/canopy-mq/outbox-migrations/ — schema, indexes and migration files are described once in the data-models index. canopy-enrollment both publishes and subscribes (boot.subscriber.subscribe(…​) on canopy-enrollment.events in services/canopy-enrollment/src/main.rs; the handler commits the domain write and event_inbox.processed_at in one transaction), so event_inbox is live here.

idempotency_keys

The fleet-wide idempotent-POST cache (#434 / #1463), created outside this service’s migrations/ directory and described once in the data-models index.

periodic_report_completions (#1107)

Per-(certification_id, generation) completion tombstones for the periodic-report action pipeline — the projection that makes the 3730 trigger/completion race converge from both sides: the schedule API refuses a periodic_report-sourced action whose tombstone exists (completion-before-trigger), and the consumer that records a tombstone cancels a still-scheduled matching action in the same inbox transaction (trigger-before-completion). Both paths serialize on a per-(certification, generation) advisory lock. Written by the renewal.snap_periodic_report_processed consumer; keys are application-level cross-service references (canopy-renewals owns the certification/cycle rows, ADR-001).

enrollment_reopens (#1108)

Append-only reopen receipts for the NARROW Chart 3730.1 periodic-report reopen: one row per reopened ENACTED periodic_report-sourced action (UNIQUE(adverse_action_id) — the idempotency key; a replayed reopen returns the stored row). received_date is the PRORATION ANCHOR the issuance path reads (the receipt month’s allotment prorates from it — reopen_proration_anchor matches the anchor’s month to the requested benefit month); actor audits who commanded it. The accompanying enrollment mutation (status restored, terminated_*/retention cleared, lifecycle_revision bumped) happens in the same transaction under the global lock order + the periodic-report advisory lock; the action row itself stays enacted (history — this receipt + the reopened signal ARE the reopen record). Missed months between termination and receipt are NOT restored (#1113).

enrollment_continuations (#1659)

ONE row per continuing determination received for a live enrollment — the apply-once ledger (UNIQUE (enrollment_id, determination_id); operation_id UNIQUE = the claimed DeterminationOperationId, the CAS record-back spine) and the causal history (determined_at NOT NULL, previous_determination_id, indexed newest-first by idx_enrollment_continuations_enrollment). Carries the signed provenance (basis_kind CHECK-limited to CONTINUATION_CLASS_KINDS — a DB test asserts the token set equals the Rust const; upstream_application_id; postponement_episode_id, present iff in_cert_conversion), the verdict (eligible), the before/after figures (previous_amount/previous_end NOT NULL; new_amount/new_end NULL iff classification = 'termination_staged'), benefit_effective_date, the DISJOINT TOTAL classification (immediate | reduction_staged | extend_now_reduce_later | termination_staged | no_change) and the row’s status (applied | staged | partially_applied | superseded | vetoed | cancelled). The three staging classes carry their adverse_action_id (FK enrollment_pending_terminations) unless the row died before staging (superseded / cancelled) — the CHECK forces action-then-row insert order; idx_enrollment_continuations_open_action (partial, WHERE status IN ('staged','partially_applied')) is the enact-sweep join. lifecycle_revision_before NOT NULL / lifecycle_revision_after NULL until fully applied (no_change records _after = _before with no bump); supplemental_issuance_id (UNIQUE FK snap_benefit_issuances) links the one supplement; applied_at is the transaction’s now() (audit only, never an ordering key). Terminal statuses: superseded (an older/equal arrival, or an open row a newer one replaced — its action cancelled), vetoed / cancelled (the staged action died; a household leaving the live set mid-apply also records cancelled). #1703 adds certification_category (TEXT NULL; since #2209 under the length CHECK length(certification_category) BETWEEN 1 AND 64 — the four-token CHECK and its CHECK-equals-Rust pin are gone, canopy_contracts_snap::CertificationCategory being a shape-validated newtype; the authority is the booted pack’s [[snap.certification.categories]], named in the column comment): the category the continuing determination assigned, validated by continuation::arm against the codes canopy-enrollment loaded from ITS pack (an undeclared token is an ArmDefect to the DLQ, never an apply) and stored VERBATIM by continuation::arm::Ctx::row (enrollment never reads its meaning) and projected onto ContinuationAppliedV1.certification_category by continuation::payloads::applied_payload for BOTH halves of a staged apply (the delayed enactment is row-driven) — canopy-renewals makes it the converted certification’s certification_type. NULL iff the determination assigned none (a denial’s termination_staged row).

snap_enrollment_successors

ONE row per renewal application (renewal_application_id PK = the event’s upstream_application_id) whose in-period recertification decision was signed under recert_approval: the newest decision (determination_id, determined_at — the causal::supersedes inputs; decision ∈ approved | denied), the new period (benefit_effective_date = the old end + 1, the closure date of a denial; certification_end_date, NULL on a denial), the approval’s WHOLE payload (event JSONB, present iff approved — the CHECK pair; the due pass lands it through the ordinary create path), status ∈ scheduled | withdrawn | landed | superseded_by_live_row | refused (a DB test asserts both CHECK token sets equal the contracts' SuccessorDecision::ALL / SuccessorStatus::ALL), denial_reason (the reason the expiry-time closure publishes), refusal_reason (present iff refused — a 7 CFR 273.17 restoration candidate), enrollment_id (present iff landed; FK to snap_enrollments). The partial UNIQUE (household_id) WHERE status = 'scheduled' is the one-renewal-in-force rule; idx_snap_enrollment_successors_due (status, benefit_effective_date) serves the sweep’s due pass and idx_snap_enrollment_successors_household the reads.

snap_ebt_account_activity (#1744)

The last EBT account activity canopy-enrollment has learned of, one row per processor account (ebt_account_id PK, matched against snap_enrollments.ebt_account_id). last_activity_on (DATE) is the latest client-initiated debit or credit observed; the consumer’s upsert keeps the later date, so a replayed or out-of-order observation never moves it backwards. observed_at (TIMESTAMPTZ) is the envelope timestamp of the observation that wrote the row, bound by the consumer with no default. source is CHECK-limited to the ActivitySource tokens (processor_inactive_accounts_file, processor_transaction_feed, operator). Written by the ebt.account_activity.observed consumer under either approach; the daily pass left-joins it to count expungements made with no observation (expunged_unobserved). No FK: the account id is the processor’s (migration 20270216000000_ebt_account_activity.sql).

scheduler_runs (#1211)

Wall-clock window fence for the service’s daily scheduler ticks (canopy-enrollment.scheduler, the expungement job; canopy-enrollment.expiry-sweep, the #1661 certification-expiry sweep — a distinct name so the two daily legs are never mutually exclusive on the cluster-global advisory lock). Schema single-sourced in crates/canopy-db/scheduler-migrations/ and parity-gated by cargo xtask outbox-migrations; documented ONCE in the data-models index.

Relationships

Intra-database foreign keys only (relationship-only; columns live in the Tables list):

Diagram

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 409 benefit_month_already_issued mapping 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 (migration 20260802000000)

  • 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-month benefit_month CHECK)

  • 20260723180000_monthly_issuance_amount.sql — #993: renames snap_enrollments.max_monthly_allotment to monthly_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_completions tombstone table, PK (certification_id, generation)

  • 20260730000000_enrollment_reopens.sql — #1108: the enrollment_reopens append-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) + the snap_enrollments_one_live_per_household partial 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, then SET NOT NULL) — the household-facing reason line snapshotted at schedule time

  • 20260821000000_restayed_link_state.sql — #1263: restayed joins the termination_appeal_links status CHECK (stayed / restayed / released / vetoed) — the final-appeal stay era

  • 20260829000000_enact_sweep_claims.sql — #1220: the sweep_claimed_at / sweep_claimed_by lease pair on enrollment_pending_terminations + idx_pending_terminations_due_scheduled

  • 20260905000000_create_scheduler_runs.sql — the generated #1211 window-fence table (single-sourced in crates/canopy-db/scheduler-migrations/); documented once in the data-models index

  • 20261209000000_uprov_b_enrollment_provenance.sql — #788: the effective_date_basis + benefit_effective_date provenance pair on snap_enrollments

  • 20261221000000_expiry_sweep_and_combined_allotment.sql — #1661: snap_enrollments.expired_at; the idx_snap_enrollments_expiry_scan partial index; snap_benefit_issuances.combined + benefit_months_covered with the range + pair CHECKs; the issuance_status CHECK widened with cancelled (DROP+ADD). Transactional, NOT CONCURRENTLY (#1196).

  • 20261222000000_issuance_covered_next_month.sql — #1692: covered_next_month_amount + its pair/bounds CHECKs, btree_gist, and the snap_issuances_no_overlapping_coverage EXCLUDE belt (transactional, NOT CONCURRENTLY).

  • 20261225000000_continuations_and_issuance_kind.sql — #1659: the enrollment_continuations ledger + its two indexes; snap_enrollments.determined_at; snap_benefit_issuances.issuance_kind (7 CFR 274.1(h)(4)) + supplemental_of_continuation_id with 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 plain idx_snap_issuances_enrollment_month_all, and the coverage EXCLUDE re-created for regular rows only; enrollment_pending_terminations.proposed_benefit_amount + target_certification_end_date with 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) + the snap_enrollments_benefit_month_prices_is_array CHECK (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: the snap_enrollments_certification_window_check CHECK (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_check DROP+ADDed under its own name without reversed (pending / issued / failed / cancelled; failed reserved for #1553; the migration’s own comments cite #1112, the notice carriers, in error), VALIDATED — no writer ever produced a reversed row, 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_kind CHECK re-declared under the same name over CONTINUATION_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 by CHECK (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_kind CHECK re-declared again under the same name over the FOUR-token CONTINUATION_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: the snap_enrollment_successors table (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), the snap_issuances_expungement_dispatch_needs_event_chk pair CHECK and the partial UNIQUE idx_snap_issuances_expungement_notice_event; clears expungement_notice_sent_at on 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) and awaiting_regeneration; additive, NULL keys on rows recorded before

  • 20270216000000_ebt_account_activity.sql — #1744: the snap_ebt_account_activity table with its source CHECK; observed_at has no default (#2589); the partial index idx_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 the snap_issuances_expungement_staged_needs_event_chk and snap_issuances_expungement_restage_count_chk CHECKs; backfills the staging day of every row with an event id from expungement_notice_sent_at on 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: drops enrollment_pending_terminations.recipient_name and recipient_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 live regular rows 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.

Edit this page · default