-- CreateTable CREATE TABLE "cart_items" ( "id" TEXT NOT NULL, "quantity" INTEGER NOT NULL DEFAULT 1, "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" TIMESTAMP(3) NOT NULL, "userId" TEXT NOT NULL, "componentId" TEXT NOT NULL, CONSTRAINT "cart_items_pkey" PRIMARY KEY ("id") ); -- CreateIndex CREATE UNIQUE INDEX "cart_items_userId_componentId_key" ON "cart_items"("userId", "componentId"); -- AddForeignKey ALTER TABLE "cart_items" ADD CONSTRAINT "cart_items_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "cart_items" ADD CONSTRAINT "cart_items_componentId_fkey" FOREIGN KEY ("componentId") REFERENCES "components"("id") ON DELETE CASCADE ON UPDATE CASCADE;