Fix UserController permission serialization and include current updates
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "Opportunity" (
|
||||
"id" TEXT NOT NULL,
|
||||
"cwOpportunityId" INTEGER NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"notes" TEXT,
|
||||
"typeName" TEXT,
|
||||
"typeCwId" INTEGER,
|
||||
"stageName" TEXT,
|
||||
"stageCwId" INTEGER,
|
||||
"statusName" TEXT,
|
||||
"statusCwId" INTEGER,
|
||||
"priorityName" TEXT,
|
||||
"priorityCwId" INTEGER,
|
||||
"ratingName" TEXT,
|
||||
"ratingCwId" INTEGER,
|
||||
"source" TEXT,
|
||||
"campaignName" TEXT,
|
||||
"campaignCwId" INTEGER,
|
||||
"primarySalesRepName" TEXT,
|
||||
"primarySalesRepIdentifier" TEXT,
|
||||
"primarySalesRepCwId" INTEGER,
|
||||
"secondarySalesRepName" TEXT,
|
||||
"secondarySalesRepIdentifier" TEXT,
|
||||
"secondarySalesRepCwId" INTEGER,
|
||||
"companyCwId" INTEGER,
|
||||
"companyName" TEXT,
|
||||
"contactCwId" INTEGER,
|
||||
"contactName" TEXT,
|
||||
"siteCwId" INTEGER,
|
||||
"siteName" TEXT,
|
||||
"customerPO" TEXT,
|
||||
"totalSalesTax" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
||||
"locationName" TEXT,
|
||||
"locationCwId" INTEGER,
|
||||
"departmentName" TEXT,
|
||||
"departmentCwId" INTEGER,
|
||||
"expectedCloseDate" TIMESTAMP(3),
|
||||
"pipelineChangeDate" TIMESTAMP(3),
|
||||
"dateBecameLead" TIMESTAMP(3),
|
||||
"closedDate" TIMESTAMP(3),
|
||||
"closedFlag" BOOLEAN NOT NULL DEFAULT false,
|
||||
"closedByName" TEXT,
|
||||
"closedByCwId" INTEGER,
|
||||
"companyId" TEXT,
|
||||
"cwLastUpdated" TIMESTAMP(3),
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "Opportunity_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Opportunity_cwOpportunityId_key" ON "Opportunity"("cwOpportunityId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Opportunity" ADD CONSTRAINT "Opportunity_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "Company"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
+71
-2
@@ -75,8 +75,9 @@ model Company {
|
||||
cw_CompanyId Int @unique
|
||||
cw_Identifier String @unique
|
||||
|
||||
credentials Credential[]
|
||||
unifiSites UnifiSite[]
|
||||
credentials Credential[]
|
||||
unifiSites UnifiSite[]
|
||||
opportunities Opportunity[]
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
@@ -85,6 +86,7 @@ model Company {
|
||||
model CatalogItem {
|
||||
id String @id @default(cuid())
|
||||
cwCatalogId Int @unique
|
||||
identifier String? @unique
|
||||
name String
|
||||
description String?
|
||||
customerDescription String?
|
||||
@@ -115,6 +117,73 @@ model CatalogItem {
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model Opportunity {
|
||||
id String @id @default(cuid())
|
||||
cwOpportunityId Int @unique
|
||||
name String
|
||||
notes String?
|
||||
|
||||
// Stage / status / priority / type / rating stored as JSON references
|
||||
// so we don't need separate lookup tables for CW enums
|
||||
typeName String?
|
||||
typeCwId Int?
|
||||
stageName String?
|
||||
stageCwId Int?
|
||||
statusName String?
|
||||
statusCwId Int?
|
||||
priorityName String?
|
||||
priorityCwId Int?
|
||||
ratingName String?
|
||||
ratingCwId Int?
|
||||
source String?
|
||||
campaignName String?
|
||||
campaignCwId Int?
|
||||
|
||||
// Sales rep references
|
||||
primarySalesRepName String?
|
||||
primarySalesRepIdentifier String?
|
||||
primarySalesRepCwId Int?
|
||||
secondarySalesRepName String?
|
||||
secondarySalesRepIdentifier String?
|
||||
secondarySalesRepCwId Int?
|
||||
|
||||
// Company / contact / site
|
||||
companyCwId Int?
|
||||
companyName String?
|
||||
contactCwId Int?
|
||||
contactName String?
|
||||
siteCwId Int?
|
||||
siteName String?
|
||||
customerPO String?
|
||||
|
||||
// Financials
|
||||
totalSalesTax Float @default(0)
|
||||
|
||||
// Location / department
|
||||
locationName String?
|
||||
locationCwId Int?
|
||||
departmentName String?
|
||||
departmentCwId Int?
|
||||
|
||||
// Dates
|
||||
expectedCloseDate DateTime?
|
||||
pipelineChangeDate DateTime?
|
||||
dateBecameLead DateTime?
|
||||
closedDate DateTime?
|
||||
closedFlag Boolean @default(false)
|
||||
closedByName String?
|
||||
closedByCwId Int?
|
||||
|
||||
// Internal relation to Company (optional, linked by cwCompanyId)
|
||||
companyId String?
|
||||
company Company? @relation(fields: [companyId], references: [id])
|
||||
|
||||
cwLastUpdated DateTime?
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model CredentialType {
|
||||
id String @id @default(cuid())
|
||||
name String @unique
|
||||
|
||||
Reference in New Issue
Block a user