25 lines
1.2 KiB
SQL
25 lines
1.2 KiB
SQL
-- اعلان درونبرنامهای مشتری بههمراه سوئیچ پیامک «فاکتور آماده شد»
|
|
ALTER TABLE "SystemSettings" ADD COLUMN "smsPricingReady" BOOLEAN NOT NULL DEFAULT true;
|
|
|
|
CREATE TABLE "CustomerNotification" (
|
|
"id" TEXT NOT NULL,
|
|
"customerId" TEXT NOT NULL,
|
|
"orderId" TEXT,
|
|
"event" TEXT NOT NULL,
|
|
"title" TEXT NOT NULL,
|
|
"body" TEXT NOT NULL,
|
|
"tone" "NotificationTone" DEFAULT 'info',
|
|
"link" TEXT,
|
|
"isRead" BOOLEAN NOT NULL DEFAULT false,
|
|
"smsSent" BOOLEAN NOT NULL DEFAULT false,
|
|
"sentAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
CONSTRAINT "CustomerNotification_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
CREATE INDEX "CustomerNotification_customerId_isRead_idx" ON "CustomerNotification"("customerId", "isRead");
|
|
CREATE INDEX "CustomerNotification_sentAt_idx" ON "CustomerNotification"("sentAt");
|
|
|
|
ALTER TABLE "CustomerNotification" ADD CONSTRAINT "CustomerNotification_customerId_fkey" FOREIGN KEY ("customerId") REFERENCES "Customer"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
ALTER TABLE "CustomerNotification" ADD CONSTRAINT "CustomerNotification_orderId_fkey" FOREIGN KEY ("orderId") REFERENCES "Order"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|