Skip to content

Add user soft deletion and audit trails#55

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/add-user-soft-deletion-audit-trails
Draft

Add user soft deletion and audit trails#55
Copilot wants to merge 2 commits into
mainfrom
copilot/add-user-soft-deletion-audit-trails

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 23, 2026

User deletions were removing records outright, leaving no recovery path and no record of who changed what. This adds soft deletion for portal users and records a lightweight audit trail for user lifecycle changes.

  • Data model

    • Added deletedAt / deletedByClerkUserId to User
    • Added UserAuditTrail for per-user event history (action, actor, before/after, metadata, timestamp)
  • Behavior changes

    • Converted portal user deletion to soft delete
    • Blocked edits/moves on soft-deleted users
    • Kept Clerk webhook sync aligned with soft-delete semantics
  • Audit logging

    • Logged user create/update/move/delete events
    • Captured actor identity and field diffs for updates
    • Stored webhook-driven create/delete events as system actions
  • Admin UX

    • Added audit trail rendering in the user/alumni edit modals
    • Surfaced recent activity inline with the record being edited
await tx.user.update({
  where: { id: input.id },
  data: {
    deletedAt: new Date(),
    deletedByClerkUserId: ctx.user?.id ?? null,
  },
});

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 23, 2026

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

Project Deployment Actions Updated (UTC)
solar-car-website-next Ready Ready Preview, Comment May 23, 2026 7:34pm

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