-- CreateTable
CREATE TABLE "OperatorSettings" (
    "id" TEXT NOT NULL PRIMARY KEY,
    "userId" TEXT NOT NULL,
    "marketplaceEnabled" BOOLEAN NOT NULL DEFAULT false,
    "pricePerMToken" REAL NOT NULL DEFAULT 0.10,
    "minPrice" REAL NOT NULL DEFAULT 0.01,
    "maxPrice" REAL NOT NULL DEFAULT 1.00,
    "autoPrice" BOOLEAN NOT NULL DEFAULT true,
    "availableModels" TEXT NOT NULL DEFAULT '[]',
    "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" DATETIME NOT NULL,
    CONSTRAINT "OperatorSettings_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);

-- CreateTable
CREATE TABLE "MarketplaceEarning" (
    "id" TEXT NOT NULL PRIMARY KEY,
    "operatorId" TEXT NOT NULL,
    "deviceId" TEXT NOT NULL,
    "model" TEXT NOT NULL,
    "tokensIn" INTEGER NOT NULL,
    "tokensOut" INTEGER NOT NULL,
    "revenue" REAL NOT NULL,
    "operatorShare" REAL NOT NULL,
    "consumerId" TEXT NOT NULL,
    "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);

-- CreateIndex
CREATE UNIQUE INDEX "OperatorSettings_userId_key" ON "OperatorSettings"("userId");

-- CreateIndex
CREATE INDEX "MarketplaceEarning_operatorId_idx" ON "MarketplaceEarning"("operatorId");

-- CreateIndex
CREATE INDEX "MarketplaceEarning_createdAt_idx" ON "MarketplaceEarning"("createdAt");
