-- CreateTable
CREATE TABLE "facebook_ad_stat" (
    "id" SERIAL NOT NULL,
    "date" TIMESTAMP(3) NOT NULL,
    "spend" DOUBLE PRECISION NOT NULL,
    "leads" INTEGER NOT NULL,
    "purchases" INTEGER NOT NULL,
    "impressions" INTEGER NOT NULL,
    "clicks" INTEGER NOT NULL,
    "fbAdId" TEXT NOT NULL,
    "fbAdgroupId" TEXT NOT NULL,
    "fbCampaignId" TEXT NOT NULL,
    "fbAccountId" TEXT NOT NULL,
    "adId" INTEGER NOT NULL,

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

-- CreateIndex
CREATE UNIQUE INDEX "facebook_ad_stat_date_adId_key" ON "facebook_ad_stat"("date", "adId");

-- AddForeignKey
ALTER TABLE "facebook_ad_stat" ADD CONSTRAINT "facebook_ad_stat_adId_fkey" FOREIGN KEY ("adId") REFERENCES "facebook_ad"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
