-- CreateTable
CREATE TABLE "MiniGameConfig" (
    "id" TEXT NOT NULL,
    "guildId" TEXT NOT NULL,
    "gameKey" TEXT NOT NULL,
    "enabled" BOOLEAN NOT NULL DEFAULT false,
    "channelId" TEXT,
    "updatedAt" TIMESTAMP(3) NOT NULL,

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

-- CreateTable
CREATE TABLE "RefinementProfile" (
    "userId" TEXT NOT NULL,
    "guildId" TEXT NOT NULL,
    "gold" INTEGER NOT NULL DEFAULT 1000,
    "weaponLevel" INTEGER NOT NULL DEFAULT 0,
    "maxWeaponLevel" INTEGER NOT NULL DEFAULT 0,
    "durability" INTEGER NOT NULL DEFAULT 10,
    "tryCount" INTEGER NOT NULL DEFAULT 0,
    "successCount" INTEGER NOT NULL DEFAULT 0,
    "failCount" INTEGER NOT NULL DEFAULT 0,
    "destroyCount" INTEGER NOT NULL DEFAULT 0,
    "battleWin" INTEGER NOT NULL DEFAULT 0,
    "battleLoss" INTEGER NOT NULL DEFAULT 0,
    "isDisabled" BOOLEAN NOT NULL DEFAULT false,
    "lastCheckIn" TIMESTAMP(3),
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,

    CONSTRAINT "RefinementProfile_pkey" PRIMARY KEY ("userId","guildId")
);

-- CreateTable
CREATE TABLE "ActivityLog" (
    "id" TEXT NOT NULL,
    "guildId" TEXT NOT NULL,
    "hour" INTEGER NOT NULL,
    "dayOfWeek" INTEGER NOT NULL,
    "count" INTEGER NOT NULL DEFAULT 0,
    "weekStart" TIMESTAMP(3) NOT NULL,

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

-- CreateTable
CREATE TABLE "FeverState" (
    "guildId" TEXT NOT NULL,
    "isActive" BOOLEAN NOT NULL DEFAULT false,
    "peakHour" INTEGER,
    "bonusRate" DOUBLE PRECISION NOT NULL DEFAULT 0.1,
    "expiresAt" TIMESTAMP(3),
    "updatedAt" TIMESTAMP(3) NOT NULL,

    CONSTRAINT "FeverState_pkey" PRIMARY KEY ("guildId")
);

-- CreateIndex
CREATE INDEX "MiniGameConfig_guildId_idx" ON "MiniGameConfig"("guildId");

-- CreateIndex
CREATE UNIQUE INDEX "MiniGameConfig_guildId_gameKey_key" ON "MiniGameConfig"("guildId", "gameKey");

-- CreateIndex
CREATE INDEX "RefinementProfile_guildId_weaponLevel_idx" ON "RefinementProfile"("guildId", "weaponLevel" DESC);

-- CreateIndex
CREATE INDEX "ActivityLog_guildId_weekStart_idx" ON "ActivityLog"("guildId", "weekStart");

-- CreateIndex
CREATE UNIQUE INDEX "ActivityLog_guildId_hour_dayOfWeek_weekStart_key" ON "ActivityLog"("guildId", "hour", "dayOfWeek", "weekStart");
