crm2
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
CREATE TABLE "CrmContactEntry" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"type" TEXT NOT NULL DEFAULT 'NOTE',
|
||||
"summary" TEXT NOT NULL,
|
||||
"body" TEXT NOT NULL,
|
||||
"contactAt" DATETIME NOT NULL,
|
||||
"customerId" TEXT,
|
||||
"vendorId" TEXT,
|
||||
"createdById" TEXT,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" DATETIME NOT NULL,
|
||||
CONSTRAINT "CrmContactEntry_customerId_fkey" FOREIGN KEY ("customerId") REFERENCES "Customer" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT "CrmContactEntry_vendorId_fkey" FOREIGN KEY ("vendorId") REFERENCES "Vendor" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT "CrmContactEntry_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "User" ("id") ON DELETE SET NULL ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
CREATE INDEX "CrmContactEntry_customerId_contactAt_idx" ON "CrmContactEntry"("customerId", "contactAt");
|
||||
|
||||
CREATE INDEX "CrmContactEntry_vendorId_contactAt_idx" ON "CrmContactEntry"("vendorId", "contactAt");
|
||||
@@ -18,6 +18,7 @@ model User {
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
userRoles UserRole[]
|
||||
contactEntries CrmContactEntry[]
|
||||
}
|
||||
|
||||
model Role {
|
||||
@@ -115,6 +116,7 @@ model Customer {
|
||||
notes String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
contactEntries CrmContactEntry[]
|
||||
}
|
||||
|
||||
model Vendor {
|
||||
@@ -132,4 +134,21 @@ model Vendor {
|
||||
notes String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
contactEntries CrmContactEntry[]
|
||||
}
|
||||
|
||||
model CrmContactEntry {
|
||||
id String @id @default(cuid())
|
||||
type String @default("NOTE")
|
||||
summary String
|
||||
body String
|
||||
contactAt DateTime
|
||||
customerId String?
|
||||
vendorId String?
|
||||
createdById String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
customer Customer? @relation(fields: [customerId], references: [id], onDelete: Cascade)
|
||||
vendor Vendor? @relation(fields: [vendorId], references: [id], onDelete: Cascade)
|
||||
createdBy User? @relation(fields: [createdById], references: [id], onDelete: SetNull)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user