Creating import&export excel

This commit is contained in:
2026-09-15 17:33:05 +03:30
parent 9ae176bec0
commit 44f9849d0e
26 changed files with 3682 additions and 474 deletions
@@ -0,0 +1,29 @@
-- CreateTable
CREATE TABLE IF NOT EXISTS "OrgRole" (
"id" TEXT NOT NULL,
"organizationId" TEXT NOT NULL,
"name" TEXT NOT NULL,
"description" TEXT NOT NULL DEFAULT '',
"color" TEXT NOT NULL DEFAULT 'teal',
"permissions" TEXT[] DEFAULT ARRAY[]::TEXT[],
"systemKey" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "OrgRole_pkey" PRIMARY KEY ("id")
);
CREATE UNIQUE INDEX IF NOT EXISTS "OrgRole_organizationId_name_key" ON "OrgRole"("organizationId", "name");
CREATE INDEX IF NOT EXISTS "OrgRole_organizationId_idx" ON "OrgRole"("organizationId");
ALTER TABLE "OrgRole" DROP CONSTRAINT IF EXISTS "OrgRole_organizationId_fkey";
ALTER TABLE "OrgRole" ADD CONSTRAINT "OrgRole_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "User" ADD COLUMN IF NOT EXISTS "isActive" BOOLEAN NOT NULL DEFAULT true;
ALTER TABLE "User" ADD COLUMN IF NOT EXISTS "lastLoginAt" TIMESTAMP(3);
ALTER TABLE "User" ADD COLUMN IF NOT EXISTS "orgRoleId" TEXT;
CREATE INDEX IF NOT EXISTS "User_orgRoleId_idx" ON "User"("orgRoleId");
ALTER TABLE "User" DROP CONSTRAINT IF EXISTS "User_orgRoleId_fkey";
ALTER TABLE "User" ADD CONSTRAINT "User_orgRoleId_fkey" FOREIGN KEY ("orgRoleId") REFERENCES "OrgRole"("id") ON DELETE SET NULL ON UPDATE CASCADE;
+24
View File
@@ -150,6 +150,7 @@ model Organization {
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
users User[]
orgRoles OrgRole[]
companies Company[]
people Person[]
pipelines Pipeline[]
@@ -199,6 +200,10 @@ model User {
role UserRole @default(sales)
/// مسیر فایل آواتار در فضای آپلود
avatarStorageKey String?
isActive Boolean @default(true)
lastLoginAt DateTime?
orgRoleId String?
orgRole OrgRole? @relation(fields: [orgRoleId], references: [id], onDelete: SetNull)
emailVerifiedAt DateTime?
mobileVerifiedAt DateTime?
organizationId String
@@ -229,6 +234,25 @@ model User {
@@unique([mobile])
@@index([organizationId])
@@index([email])
@@index([orgRoleId])
}
model OrgRole {
id String @id @default(cuid())
organizationId String
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
name String
description String @default("")
color String @default("teal")
permissions String[] @default([])
/// owner | admin | sales | support — نقش‌های سیستمی قابل حذف نیستند
systemKey String?
users User[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([organizationId, name])
@@index([organizationId])
}
model Company {