Skip to content

OUT-3734 | Schema: add TaskReminderSent table + TaskReminderType enum#1229

Merged
arpandhakal merged 1 commit into
feature/email-remindersfrom
arpandhakal/out-3734-schema-add-taskremindersent-table-taskremindertype-enum
May 25, 2026
Merged

OUT-3734 | Schema: add TaskReminderSent table + TaskReminderType enum#1229
arpandhakal merged 1 commit into
feature/email-remindersfrom
arpandhakal/out-3734-schema-add-taskremindersent-table-taskremindertype-enum

Conversation

@arpandhakal
Copy link
Copy Markdown
Collaborator

@arpandhakal arpandhakal commented May 15, 2026

Summary

  • Adds TaskReminderType enum and TaskReminderSents table — the idempotency ledger for reminder emails (Milestone 1).
  • Unique constraint on (taskId, recipientId, reminderType) is the dedupe primitive so retries and manual re-triggers cannot double-send.
  • FK to Tasks(id) with ON DELETE CASCADE; workspaceId carried for tenancy parity with the rest of the schema.

Test plan

  • prisma validate passes
  • prisma migrate dev applies cleanly on local Postgres
  • prisma generate produces the expected types
  • Duplicate insert on (taskId, recipientId, reminderType) raises a unique-constraint violation
  • Hard-deleting the parent Task cascades and removes ledger rows
  • Migration applies cleanly in staging on deploy

🤖 Generated with Claude Code

@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 15, 2026

OUT-3734

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tasks-app Ready Ready Preview, Comment May 18, 2026 10:50am

Request Review

@arpandhakal arpandhakal changed the title OUT-3734 | https://linear.app/assemblycom/issue/OUT-3734/schema-add-taskremindersent-table-taskremindertype-enum OUT-3734 | Schema: add TaskReminderSent table + TaskReminderType enum May 15, 2026
@arpandhakal arpandhakal self-assigned this May 15, 2026
@arpandhakal arpandhakal changed the base branch from main to feature/email-reminders May 15, 2026 09:19
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 15, 2026

Greptile Summary

This PR introduces the TaskReminderSents idempotency ledger (Milestone 1) — a new TaskReminderType enum with six reminder categories and a TaskReminderSents table that deduplicates outbound reminder emails via a unique constraint on (taskId, recipientId, reminderType).

  • Adds TaskReminderType enum (NO_DUE_DATE_3D/7D, DUE_DATE_BEFORE_3D, DUE_DATE_TODAY, DUE_DATE_OVERDUE_3D/7D) and the TaskReminderSents table with a cascade FK to Tasks.
  • Migration DDL is consistent with the Prisma schema; the unique index is the sole dedup primitive and blocks retries from double-sending.

Confidence Score: 4/5

Safe to merge; the schema and migration are internally consistent. Two non-blocking issues are worth revisiting before the reminder job ships.

The migration and schema are in sync, CASCADE FK is correctly wired, and the dedup constraint aligns with the stated design intent. The main concerns are that the lifetime-once unique constraint may silently skip reminders after task state resets, and workspaceId has no index despite being the tenancy column — both are worth addressing before the reminder job is turned on in production but neither blocks the schema migration itself.

prisma/schema/taskReminderSent.prisma — unique constraint semantics and missing workspaceId index.

Important Files Changed

Filename Overview
prisma/migrations/20260515091539_add_task_reminder_sents_table/migration.sql Creates the TaskReminderType enum and TaskReminderSents table with a composite unique index and CASCADE FK; migration DDL matches the Prisma schema exactly.
prisma/schema/taskReminderSent.prisma New model and enum are well-structured; two P2 notes: the lifetime-once unique constraint may block legitimate re-sends after task state resets, and workspaceId lacks an index for tenant-scoped lookups.
prisma/schema/task.prisma Single-line addition of the taskReminderSents back-relation; no issues.

Reviews (1): Last reviewed commit: "feat(OUT-3734): add TaskReminderSents ta..." | Re-trigger Greptile

reminderType TaskReminderType
sentAt DateTime @default(now())

@@unique([taskId, recipientId, reminderType])
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Permanent dedup blocks legitimate re-sends

The unique constraint on (taskId, recipientId, reminderType) has no time dimension, so each reminder type can only fire once per task-recipient pair for the lifetime of the record. For the NO_DUE_DATE_* types this creates a concrete gap: if a user adds a due date (making the "no due date" reminders irrelevant), then later removes it again, the 3-day and 7-day nudges will never re-fire because the old ledger rows still exist. The same applies to DUE_DATE_TODAY if a due date is postponed and then reset. At minimum a comment explaining why this lifetime-once behaviour is correct, or whether the job is expected to delete stale rows before re-arming, would help prevent future confusion.

Comment on lines +19 to +20
@@unique([taskId, recipientId, reminderType])
@@map("TaskReminderSents")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Missing workspaceId index for tenant-scoped queries. The column is explicitly carried "for tenancy parity" but has no index, so any query that filters or batches by workspace (e.g., the reminder job scanning pending tasks per workspace) will do a full table scan as the table grows.

Suggested change
@@unique([taskId, recipientId, reminderType])
@@map("TaskReminderSents")
@@unique([taskId, recipientId, reminderType])
@@index([workspaceId])
@@map("TaskReminderSents")

Adds a minimal ledger to enforce reminder idempotency at the DB level.
Unique constraint on (taskId, recipientId, reminderType) is the dedupe
primitive so retries and manual re-triggers cannot double-send.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@arpandhakal arpandhakal force-pushed the arpandhakal/out-3734-schema-add-taskremindersent-table-taskremindertype-enum branch from b4fdbe6 to d3b94ad Compare May 18, 2026 10:49
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 18, 2026

Deployment failed with the following error:

Deploying Serverless Functions to multiple regions is restricted to the Pro and Enterprise plans.

Learn More: https://vercel.link/multiple-function-regions

Copy link
Copy Markdown
Collaborator

@priosshrsth priosshrsth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@arpandhakal arpandhakal merged commit 73c6caa into feature/email-reminders May 25, 2026
3 checks passed
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.

2 participants