-- CreateTable
CREATE TABLE "SubaccountMetric" (
    "id" TEXT NOT NULL,
    "subaccountId" TEXT NOT NULL,
    "name" TEXT,
    "bouncePercent" DOUBLE PRECISION,
    "spamPercent" DOUBLE PRECISION,
    "emails" INTEGER,
    "rejects" INTEGER,
    "softbounces" INTEGER,
    "hardbounces" INTEGER,
    "cycleStart" TIMESTAMP(3),
    "cycleEnd" TIMESTAMP(3),
    "cycleUsed" INTEGER,
    "cycleRemaining" INTEGER,
    "cycleMax" INTEGER,
    "spamEmails" INTEGER,
    "spamRejects" INTEGER,
    "unsubscribes" INTEGER,
    "fetchedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateIndex
CREATE INDEX "SubaccountMetric_subaccountId_idx" ON "SubaccountMetric"("subaccountId");

-- CreateIndex
CREATE INDEX "SubaccountMetric_fetchedAt_idx" ON "SubaccountMetric"("fetchedAt");

-- CreateIndex
CREATE UNIQUE INDEX "SubaccountMetric_subaccountId_cycleStart_cycleEnd_key" ON "SubaccountMetric"("subaccountId", "cycleStart", "cycleEnd");
