Skip to content

Add purpose column to NotifyLogEntry including backfill data migration#6184

Merged
jhenderson merged 2 commits intonextfrom
notify-log-entry-purpose
Mar 4, 2026
Merged

Add purpose column to NotifyLogEntry including backfill data migration#6184
jhenderson merged 2 commits intonextfrom
notify-log-entry-purpose

Conversation

@jhenderson
Copy link
Copy Markdown
Contributor

@jhenderson jhenderson commented Mar 4, 2026

Context

This PR improves how we record and reason about outbound notifications by introducing purpose on NotifyLogEntry. That gives us a consistent way to categorise emails/SMS (e.g., consent request vs reminder) based on the Notify template being used, and it will help implement the logic for the method should_be_needs_consent_request_failed in StatusGenerator::Programme (#6137)

Ticket: MAV-4087

What’s changed

  • Introduced a purpose column on notify_log_entries
  • Added a purpose enum to NotifyLogEntry, plus a helper to derive purpose from a template name
  • Updated both email and SMS delivery jobs to populate purpose when creating NotifyLogEntry records
  • Added a data migration that backfills NotifyLogEntry#purpose for existing rows using a mapping of historical Notify template IDs

@jhenderson jhenderson requested a review from a team as a code owner March 4, 2026 11:41
@jhenderson jhenderson added the data consistency Validations and data tweaks label Mar 4, 2026
@jhenderson jhenderson added this to the v7.3.0 milestone Mar 4, 2026
@jhenderson jhenderson force-pushed the notify-log-entry-purpose branch from e037c7b to 6163a87 Compare March 4, 2026 11:42
@jhenderson jhenderson modified the milestones: v7.3.0, v7.2.0 Mar 4, 2026
Comment thread app/models/notify_log_entry.rb Outdated
@jhenderson jhenderson force-pushed the notify-log-entry-purpose branch from 6163a87 to 0ed6035 Compare March 4, 2026 14:20
Comment thread app/models/notify_log_entry.rb Outdated
Comment thread app/models/notify_log_entry.rb
@jhenderson jhenderson force-pushed the notify-log-entry-purpose branch 3 times, most recently from ac72cd4 to a55a51f Compare March 4, 2026 15:02
Introduce a `purpose` enum on `NotifyLogEntry` and persist it for sent messages so
we can distinguish what kind of notification failed, not just that it failed.

This is the first step towards implementing consent “needs_*” sub-status logic
(e.g. `needs_consent_request_failed`), enabling efficient checks for failed
consent requests.

Jira-Issue: MAV-502
Add a data migration to populate `notify_log_entries.purpose` from the template
ID→name mapping. The mapping includes both current template IDs and historical
IDs (recovered from git history) so older records can be backfilled accurately.

Jira-Issue: MAV-502
@jhenderson jhenderson force-pushed the notify-log-entry-purpose branch from a55a51f to 2928762 Compare March 4, 2026 15:18
@jhenderson jhenderson merged commit c947104 into next Mar 4, 2026
13 checks passed
@jhenderson jhenderson deleted the notify-log-entry-purpose branch March 4, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data consistency Validations and data tweaks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants