-- CreateTable
CREATE TABLE "carts" (
    "id" SERIAL NOT NULL,
    "callId" TEXT NOT NULL,
    "callerId" TEXT NOT NULL,
    "productId" INTEGER NOT NULL,
    "qty" INTEGER NOT NULL DEFAULT 1,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,

    CONSTRAINT "carts_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE INDEX "carts_callId_idx" ON "carts"("callId");

-- CreateIndex
CREATE INDEX "carts_callerId_idx" ON "carts"("callerId");

-- CreateIndex
CREATE UNIQUE INDEX "carts_productId_callerId_key" ON "carts"("productId", "callerId");

-- AddForeignKey
ALTER TABLE "carts" ADD CONSTRAINT "carts_productId_fkey" FOREIGN KEY ("productId") REFERENCES "products"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
