Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
39 lines
1.0 KiB
SQL
39 lines
1.0 KiB
SQL
-- CreateEnum
|
|
CREATE TYPE "LeadStatus" AS ENUM ('NEW', 'IN_WORK', 'DONE', 'CANCELLED');
|
|
|
|
-- CreateEnum
|
|
CREATE TYPE "LeadContactType" AS ENUM ('PHONE', 'TELEGRAM');
|
|
|
|
-- CreateTable
|
|
CREATE TABLE "Lead" (
|
|
"id" TEXT NOT NULL,
|
|
"number" SERIAL NOT NULL,
|
|
"key" TEXT NOT NULL,
|
|
"name" TEXT NOT NULL,
|
|
"contact" TEXT NOT NULL,
|
|
"contactType" "LeadContactType" NOT NULL,
|
|
"locale" "Locale" NOT NULL,
|
|
"agency" TEXT,
|
|
"utm" JSONB,
|
|
"moved" BOOLEAN,
|
|
"moveWhen" TEXT,
|
|
"moveDate" TIMESTAMP(3),
|
|
"package" TEXT,
|
|
"options" JSONB,
|
|
"submittedAt" TIMESTAMP(3),
|
|
"consentAt" TIMESTAMP(3) NOT NULL,
|
|
"consentVersion" TEXT NOT NULL,
|
|
"status" "LeadStatus" NOT NULL DEFAULT 'NEW',
|
|
"adminNote" TEXT,
|
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
|
|
CONSTRAINT "Lead_pkey" PRIMARY KEY ("id")
|
|
);
|
|
|
|
-- CreateIndex
|
|
CREATE UNIQUE INDEX "Lead_number_key" ON "Lead"("number");
|
|
|
|
-- CreateIndex
|
|
CREATE INDEX "Lead_status_createdAt_idx" ON "Lead"("status", "createdAt");
|