[PR #554] [MERGED] fix: add cascade delete for share links #1041

Closed
opened 2026-02-26 19:31:35 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/documenso/documenso/pull/554
Author: @dguyen
Created: 10/13/2023
Status: Merged
Merged: 10/13/2023
Merged by: @Mythie

Base: feat/refreshHead: fix/cascade-delete-share-links


📝 Commits (1)

  • f728dd1 fix: add cascade delete for share links

📊 Changes

3 files changed (+8 additions, -3 deletions)

View changed files

📝 apps/web/src/app/(dashboard)/documents/data-table-action-dropdown.tsx (+2 -2)
packages/prisma/migrations/20231013012902_add_document_share_link_delete_cascade/migration.sql (+5 -0)
📝 packages/prisma/schema.prisma (+1 -1)

📄 Description

Description

Currently if a user creates a draft document and shares it, they will not be able to delete it.

The following is the error log when you try:

PrismaClientKnownRequestError: 
Invalid `prisma.document.delete()` invocation:

Foreign key constraint failed on the field: `DocumentShareLink_documentId_fkey (index)`
    at wn.handleRequestError (/var/task/node_modules/@prisma/client/runtime/library.js:123:6730)
    at wn.handleAndLogRequestError (/var/task/node_modules/@prisma/client/runtime/library.js:123:6119)
    at wn.request (/var/task/node_modules/@prisma/client/runtime/library.js:123:5839)
    at async l (/var/task/node_modules/@prisma/client/runtime/library.js:128:9763)
    at async deleteDraftDocument (/var/task/apps/web/.next/server/pages/api/trpc/[trpc].js:534:12)
    at async /var/task/apps/web/.next/server/pages/api/trpc/[trpc].js:1458:20
    at async resolveMiddleware (/var/task/node_modules/@trpc/server/dist/index.js:418:30)
    at async callRecursive (/var/task/node_modules/@trpc/server/dist/index.js:454:32)
    at async callRecursive (/var/task/node_modules/@trpc/server/dist/index.js:454:32)
    at async /var/task/apps/web/.next/server/pages/api/trpc/[trpc].js:2541:12 {
  code: 'P2003',
  clientVersion: '5.3.1',
  meta: { field_name: 'DocumentShareLink_documentId_fkey (index)' }
}

Changes Made

  • Added cascade delete on the DocumentShareLink document relation
  • Disable the share button for draft documents

Testing Performed

  • Tested deleting a document which contains share links

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/documenso/documenso/pull/554 **Author:** [@dguyen](https://github.com/dguyen) **Created:** 10/13/2023 **Status:** ✅ Merged **Merged:** 10/13/2023 **Merged by:** [@Mythie](https://github.com/Mythie) **Base:** `feat/refresh` ← **Head:** `fix/cascade-delete-share-links` --- ### 📝 Commits (1) - [`f728dd1`](https://github.com/documenso/documenso/commit/f728dd13c5bfec62d0ec0659dcb9f2ea61ab4a73) fix: add cascade delete for share links ### 📊 Changes **3 files changed** (+8 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `apps/web/src/app/(dashboard)/documents/data-table-action-dropdown.tsx` (+2 -2) ➕ `packages/prisma/migrations/20231013012902_add_document_share_link_delete_cascade/migration.sql` (+5 -0) 📝 `packages/prisma/schema.prisma` (+1 -1) </details> ### 📄 Description ## Description Currently if a user creates a draft document and shares it, they will not be able to delete it. The following is the error log when you try: ``` PrismaClientKnownRequestError: Invalid `prisma.document.delete()` invocation: Foreign key constraint failed on the field: `DocumentShareLink_documentId_fkey (index)` at wn.handleRequestError (/var/task/node_modules/@prisma/client/runtime/library.js:123:6730) at wn.handleAndLogRequestError (/var/task/node_modules/@prisma/client/runtime/library.js:123:6119) at wn.request (/var/task/node_modules/@prisma/client/runtime/library.js:123:5839) at async l (/var/task/node_modules/@prisma/client/runtime/library.js:128:9763) at async deleteDraftDocument (/var/task/apps/web/.next/server/pages/api/trpc/[trpc].js:534:12) at async /var/task/apps/web/.next/server/pages/api/trpc/[trpc].js:1458:20 at async resolveMiddleware (/var/task/node_modules/@trpc/server/dist/index.js:418:30) at async callRecursive (/var/task/node_modules/@trpc/server/dist/index.js:454:32) at async callRecursive (/var/task/node_modules/@trpc/server/dist/index.js:454:32) at async /var/task/apps/web/.next/server/pages/api/trpc/[trpc].js:2541:12 { code: 'P2003', clientVersion: '5.3.1', meta: { field_name: 'DocumentShareLink_documentId_fkey (index)' } } ``` ## Changes Made - Added cascade delete on the `DocumentShareLink` document relation - Disable the share button for draft documents ## Testing Performed - Tested deleting a document which contains share links --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-26 19:31:35 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/documenso#1041
No description provided.