-- CreateTable
CREATE TABLE "tbl_product_notify" (
    "id" BIGSERIAL NOT NULL,
    "user_id" BIGINT NOT NULL,
    "brand_id" BIGINT NOT NULL,
    "product_id" BIGINT NOT NULL,
    "product_name" VARCHAR(256),
    "is_email_send" BOOLEAN DEFAULT false,
    "is_notification_send" BOOLEAN DEFAULT false,
    "inserted_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
    "updated_at" TIMESTAMP(3),

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

-- CreateIndex
CREATE INDEX "tbl_product_notify_user_id_brand_id_product_id_product_name_idx" ON "tbl_product_notify"("user_id", "brand_id", "product_id", "product_name", "is_email_send", "is_notification_send");

-- AddForeignKey
ALTER TABLE "tbl_product_notify" ADD CONSTRAINT "tbl_product_notify_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "tbl_user"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "tbl_product_notify" ADD CONSTRAINT "tbl_product_notify_brand_id_fkey" FOREIGN KEY ("brand_id") REFERENCES "tbl_user"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "tbl_product_notify" ADD CONSTRAINT "tbl_product_notify_product_id_fkey" FOREIGN KEY ("product_id") REFERENCES "tbl_product"("id") ON DELETE CASCADE ON UPDATE CASCADE;
