feat: keep deletions restorable and confirm a pipeline's deals before it is removed

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-13 22:23:09 +03:30
co-authored by Cursor
parent c04582072d
commit 2cc81bb596
17 changed files with 1158 additions and 6 deletions
+22
View File
@@ -235,6 +235,9 @@ model Organization {
gamificationBadges GamificationBadge[]
gamificationUserBadges GamificationUserBadge[]
gamificationBonuses GamificationBonus[]
/// month | two_months | three_months | six_months | year | never
deletionRetention String @default("never")
deletionArchives DeletionArchive[]
}
model User {
@@ -294,6 +297,7 @@ model User {
createdRoutineTasks RoutineTask[] @relation("RoutineTaskCreator")
routineTaskEvents RoutineTaskEvent[]
routineSettings RoutineUserSettings[]
deletionArchives DeletionArchive[] @relation("DeletionActor")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@ -1859,6 +1863,24 @@ model AuditLog {
@@index([organizationId, entityType, createdAt])
}
/// نسخهٔ قابل بازگشتِ رکوردهای حذف‌شده
model DeletionArchive {
id String @id @default(cuid())
organizationId String
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
/// نام مدل پریزما
model String
entityId String
label String
snapshot Json
deletedById String?
deletedBy User? @relation("DeletionActor", fields: [deletedById], references: [id], onDelete: SetNull)
deletedAt DateTime @default(now())
@@index([organizationId, deletedAt])
@@index([organizationId, model])
}
/// فیلترهای ذخیره‌شده برای لیست‌ها و مسیرهای فروش
/// ستون‌های مخفی هر جدول برای هر کاربر (به‌ازای هر سازمان)
model UserTablePreference {