Slice 6: Schema — Notifications Log - #30
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 fromtechnical_requirements.md§2 now exist.Implements Slice 6 of the backend foundation PRD (#1).
Changes
src/SubVora.Domain/Entities/NotificationLog.cs:Id,UserSubscriptionId,SentAt,AlertDaysAdvancesrc/SubVora.Infrastructure/Data/Configurations/NotificationLogConfiguration.cs: FKuser_subscription_id → user_subscriptions.id ON DELETE CASCADE, compositeUNIQUE (user_subscription_id, alert_days_advance, sent_at)src/SubVora.Infrastructure/Data/AppDbContext.cs: newDbSet<NotificationLog>src/SubVora.Infrastructure/Migrations/20260711185132_AddNotificationsLog.cs: generated migration, continues the Slice 2-5 historytests/SubVora.Infrastructure.Tests/NotificationLogTests.cs: 3 new Testcontainers testsSmallest 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 errorsdotnet 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 andalert_days_advanceround-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 throwsDbUpdateExceptionon the second insert — the exact guarantee the future renewal-alert job depends on for idempotency.Acceptance criteria (from #7)
notifications_logtable created matchingtechnical_requirements.md§2, including the composite unique constraint.user_subscriptionsconfirmed via test.Closes #7