/*
  Warnings:

  - A unique constraint covering the columns `[offerId]` on the table `tonic_campaign` will be added. If there are existing duplicate values, this will fail.
  - A unique constraint covering the columns `[providerAccountId]` on the table `tonic_campaign` will be added. If there are existing duplicate values, this will fail.
  - A unique constraint covering the columns `[providerAccountId,externalId]` on the table `tonic_campaign` will be added. If there are existing duplicate values, this will fail.

*/
-- AlterTable
ALTER TABLE "tonic_campaign" ADD COLUMN     "offerId" INTEGER,
ADD COLUMN     "providerAccountId" INTEGER;

-- CreateIndex
CREATE UNIQUE INDEX "tonic_campaign_offerId_key" ON "tonic_campaign"("offerId");

-- CreateIndex
CREATE UNIQUE INDEX "tonic_campaign_providerAccountId_key" ON "tonic_campaign"("providerAccountId");

-- CreateIndex
CREATE UNIQUE INDEX "tonic_campaign_providerAccountId_externalId_key" ON "tonic_campaign"("providerAccountId", "externalId");

-- AddForeignKey
ALTER TABLE "tonic_campaign" ADD CONSTRAINT "tonic_campaign_offerId_fkey" FOREIGN KEY ("offerId") REFERENCES "offer"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "tonic_campaign" ADD CONSTRAINT "tonic_campaign_providerAccountId_fkey" FOREIGN KEY ("providerAccountId") REFERENCES "provider_account"("id") ON DELETE SET NULL ON UPDATE CASCADE;
