Inconsistent FK ON DELETE behavior: bulk_operations.performed_by and ticket_templates.created_by default to RESTRICT #40

Open
opened 2026-08-31 21:29:46 -04:00 by jared · 0 comments
Owner

Severity: Medium

In migrations/000_baseline.sql, tickets.created_by/updated_by/assigned_to, ticket_attachments.uploaded_by, ticket_dependencies.created_by, recurring_tickets.created_by/assigned_to, and api_keys.created_by all use ON DELETE SET NULL. But bulk_operations.performed_by (~line 72) and ticket_templates.created_by (~line 241) have no ON DELETE clause, which defaults to RESTRICT.

Impact: Deleting a user who ever ran a bulk operation or created a template will hard-fail at the DB level instead of nulling out the reference, breaking the pattern used everywhere else in the schema and potentially blocking legitimate user offboarding/cleanup.

Fix: Add a migration to change both FKs to ON DELETE SET NULL, matching the rest of the schema.

**Severity:** Medium In `migrations/000_baseline.sql`, `tickets.created_by/updated_by/assigned_to`, `ticket_attachments.uploaded_by`, `ticket_dependencies.created_by`, `recurring_tickets.created_by/assigned_to`, and `api_keys.created_by` all use `ON DELETE SET NULL`. But `bulk_operations.performed_by` (~line 72) and `ticket_templates.created_by` (~line 241) have no `ON DELETE` clause, which defaults to `RESTRICT`. **Impact:** Deleting a user who ever ran a bulk operation or created a template will hard-fail at the DB level instead of nulling out the reference, breaking the pattern used everywhere else in the schema and potentially blocking legitimate user offboarding/cleanup. **Fix:** Add a migration to change both FKs to `ON DELETE SET NULL`, matching the rest of the schema.
jared added the data-integritypriority/medium labels 2026-09-08 10:15:44 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: LotusGuild/tinker_tickets#40