/*
  Warnings:

  - You are about to drop the column `callId` on the `carts` table. All the data in the column will be lost.
  - You are about to drop the column `callerId` on the `carts` table. All the data in the column will be lost.
  - A unique constraint covering the columns `[productId,userId]` on the table `carts` will be added. If there are existing duplicate values, this will fail.
  - Added the required column `userId` to the `carts` table without a default value. This is not possible if the table is not empty.

*/
-- DropIndex
DROP INDEX "carts_callId_idx";

-- DropIndex
DROP INDEX "carts_callerId_idx";

-- DropIndex
DROP INDEX "carts_productId_callerId_key";

-- AlterTable
ALTER TABLE "carts" DROP COLUMN "callId",
DROP COLUMN "callerId",
ADD COLUMN     "userId" INTEGER NOT NULL;

-- CreateIndex
CREATE INDEX "carts_userId_idx" ON "carts"("userId");

-- CreateIndex
CREATE UNIQUE INDEX "carts_productId_userId_key" ON "carts"("productId", "userId");

-- AddForeignKey
ALTER TABLE "carts" ADD CONSTRAINT "carts_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
