/*
  Warnings:

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

*/
-- DropForeignKey
ALTER TABLE "facebook_ad_stat" DROP CONSTRAINT "facebook_ad_stat_adId_fkey";

-- DropIndex
DROP INDEX "facebook_ad_stat_date_adId_key";

-- AlterTable
ALTER TABLE "facebook_ad_stat" DROP COLUMN "adId",
ADD COLUMN     "accountId" INTEGER NOT NULL;

-- CreateIndex
CREATE UNIQUE INDEX "facebook_ad_stat_date_fbAdId_key" ON "facebook_ad_stat"("date", "fbAdId");

-- AddForeignKey
ALTER TABLE "facebook_ad_stat" ADD CONSTRAINT "facebook_ad_stat_accountId_fkey" FOREIGN KEY ("accountId") REFERENCES "account"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
