/*
  Warnings:

  - You are about to drop the `BinomCampaign` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `DomainActiveAccount` table. If the table is not empty, all the data it contains will be lost.
  - You are about to drop the `DomainActiveLead` table. If the table is not empty, all the data it contains will be lost.

*/
-- DropForeignKey
ALTER TABLE "DomainActiveLead" DROP CONSTRAINT "DomainActiveLead_domainActiveAccountId_fkey";

-- DropForeignKey
ALTER TABLE "DomainActiveLead" DROP CONSTRAINT "DomainActiveLead_userId_fkey";

-- DropForeignKey
ALTER TABLE "tonic_campaign" DROP CONSTRAINT "tonic_campaign_binomCampaignId_fkey";

-- AlterTable
ALTER TABLE "user" ADD COLUMN     "timezoneId" INTEGER;

-- DropTable
DROP TABLE "BinomCampaign";

-- DropTable
DROP TABLE "DomainActiveAccount";

-- DropTable
DROP TABLE "DomainActiveLead";

-- CreateTable
CREATE TABLE "binom_campaign" (
    "id" SERIAL NOT NULL,
    "createAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updateAt" TIMESTAMP(3) NOT NULL,
    "binomCampaignName" TEXT NOT NULL,
    "binomCampaignId" TEXT,

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

-- CreateTable
CREATE TABLE "domain_active_lead" (
    "id" SERIAL NOT NULL,
    "clicks" INTEGER NOT NULL,
    "revenue" DOUBLE PRECISION NOT NULL,
    "trackerClickId" TEXT,
    "keyword" TEXT NOT NULL,
    "domainActiveAccountId" INTEGER NOT NULL,
    "userId" INTEGER,

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

-- CreateTable
CREATE TABLE "domain_active_account" (
    "id" SERIAL NOT NULL,
    "name" TEXT NOT NULL,
    "token" TEXT NOT NULL,

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

-- CreateTable
CREATE TABLE "timezone" (
    "id" SERIAL NOT NULL,
    "createDate" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "name" TEXT NOT NULL,
    "timeNumber" TEXT,

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

-- AddForeignKey
ALTER TABLE "user" ADD CONSTRAINT "user_timezoneId_fkey" FOREIGN KEY ("timezoneId") REFERENCES "timezone"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "tonic_campaign" ADD CONSTRAINT "tonic_campaign_binomCampaignId_fkey" FOREIGN KEY ("binomCampaignId") REFERENCES "binom_campaign"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "domain_active_lead" ADD CONSTRAINT "domain_active_lead_domainActiveAccountId_fkey" FOREIGN KEY ("domainActiveAccountId") REFERENCES "domain_active_account"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "domain_active_lead" ADD CONSTRAINT "domain_active_lead_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE CASCADE;
