Skip to content

Slice 6: Schema — Notifications Log - #30

Merged
rghvgrv merged 1 commit into
mainfrom
slice-6-schema-notifications-log
Jul 11, 2026
Merged

Slice 6: Schema — Notifications Log#30
rghvgrv merged 1 commit into
mainfrom
slice-6-schema-notifications-log

Conversation

@rghvgrv

@rghvgrv rghvgrv commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

What

Adds notifications_log — the idempotency guard the renewal-alert background job (Slice 22, not yet built) will use to avoid double-sending alerts. This completes the schema foundation: all 8 tables from technical_requirements.md §2 now exist.

Implements Slice 6 of the backend foundation PRD (#1).

Changes

  • src/SubVora.Domain/Entities/NotificationLog.cs: Id, UserSubscriptionId, SentAt, AlertDaysAdvance
  • src/SubVora.Infrastructure/Data/Configurations/NotificationLogConfiguration.cs: FK user_subscription_id → user_subscriptions.id ON DELETE CASCADE, composite UNIQUE (user_subscription_id, alert_days_advance, sent_at)
  • src/SubVora.Infrastructure/Data/AppDbContext.cs: new DbSet<NotificationLog>
  • src/SubVora.Infrastructure/Migrations/20260711185132_AddNotificationsLog.cs: generated migration, continues the Slice 2-5 history
  • tests/SubVora.Infrastructure.Tests/NotificationLogTests.cs: 3 new Testcontainers tests

Smallest slice of the schema batch — one table, no enums, no partial/vector columns, generated cleanly with zero hand-editing.

Verification

  • dotnet build SubVora.slnx — 0 warnings, 0 errors
  • dotnet test SubVora.slnx — 19/19 pass (2 smoke + 17 in Infrastructure.Tests, up from 14)
  • NotificationLog_PersistsAndReferencesUserSubscription: creates a real user + subscription, inserts a log row, reloads, confirms the FK and alert_days_advance round-trip.
  • NotificationLog_DeletingUserSubscription_CascadesDelete: deletes the referenced subscription, confirms the log row is gone.
  • NotificationLog_DuplicateSubscriptionAlertDaysSentAt_ViolatesUniqueConstraint: inserting the same (subscription, alert_days_advance, sent_at) tuple twice throws DbUpdateException on the second insert — the exact guarantee the future renewal-alert job depends on for idempotency.

Acceptance criteria (from #7)

  • notifications_log table created matching technical_requirements.md §2, including the composite unique constraint.
  • FK cascade to user_subscriptions confirmed via test.

Closes #7

Implements Slice 6: NotificationLog entity with FK to user_subscriptions
(ON DELETE CASCADE) and the composite UNIQUE (user_subscription_id,
alert_days_advance, sent_at) constraint the renewal-alert job (Slice 22)
will rely on to avoid double-sending alerts. Completes the schema
foundation - all 8 tables from technical_requirements.md §2 now exist.

Testcontainers tests cover: insert + FK resolution, cascade delete when
the referenced subscription is removed, and the composite unique
constraint rejecting a duplicate (subscription, alert_days, sent_at) row.

Closes #7
@rghvgrv rghvgrv self-assigned this Jul 11, 2026
@rghvgrv
rghvgrv merged commit 5c70e52 into main Jul 11, 2026
@rghvgrv
rghvgrv deleted the slice-6-schema-notifications-log branch July 12, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slice 6: Schema — Notifications Log

1 participant