-- CreateEnum
CREATE TYPE "ClickEvent" AS ENUM ('PAGE_VIEW', 'KEYWORD_BLOCK_LOADED', 'CLICK');

-- CreateTable
CREATE TABLE "inuvo_click" (
    "id" SERIAL NOT NULL,
    "url" TEXT NOT NULL,
    "referer" TEXT NOT NULL,
    "userAgent" TEXT NOT NULL,
    "query" TEXT NOT NULL,
    "fbp" TEXT NOT NULL,
    "iid" TEXT NOT NULL,
    "clickId" INTEGER NOT NULL,
    "inuvoCampaignId" INTEGER NOT NULL,

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

-- CreateTable
CREATE TABLE "click" (
    "id" SERIAL NOT NULL,
    "clickType" "ClickEvent" NOT NULL,
    "offerType" "OfferType",
    "provider" "Provider",

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

-- AddForeignKey
ALTER TABLE "inuvo_click" ADD CONSTRAINT "inuvo_click_clickId_fkey" FOREIGN KEY ("clickId") REFERENCES "click"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "inuvo_click" ADD CONSTRAINT "inuvo_click_inuvoCampaignId_fkey" FOREIGN KEY ("inuvoCampaignId") REFERENCES "inuvo_campaign"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
