-- AlterTable
ALTER TABLE "obm_core"."Discount" ADD COLUMN     "isAutoApply" BOOLEAN NOT NULL DEFAULT false,
ADD COLUMN     "isFirstTimeCustomersOnly" BOOLEAN NOT NULL DEFAULT false;

-- CreateTable
CREATE TABLE "obm_core"."DiscountUsage" (
    "id" TEXT NOT NULL,
    "discountId" TEXT NOT NULL,
    "shopId" TEXT NOT NULL,
    "usedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateIndex
CREATE INDEX "DiscountUsage_shopId_idx" ON "obm_core"."DiscountUsage"("shopId");

-- CreateIndex
CREATE INDEX "DiscountUsage_discountId_idx" ON "obm_core"."DiscountUsage"("discountId");

-- CreateIndex
CREATE UNIQUE INDEX "DiscountUsage_discountId_shopId_key" ON "obm_core"."DiscountUsage"("discountId", "shopId");

-- AddForeignKey
ALTER TABLE "obm_core"."DiscountUsage" ADD CONSTRAINT "DiscountUsage_discountId_fkey" FOREIGN KEY ("discountId") REFERENCES "obm_core"."Discount"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "obm_core"."DiscountUsage" ADD CONSTRAINT "DiscountUsage_shopId_fkey" FOREIGN KEY ("shopId") REFERENCES "obm_core"."Shop"("id") ON DELETE CASCADE ON UPDATE CASCADE;
