-- CreateEnum
CREATE TYPE "SubscriptionStatus" AS ENUM ('active', 'expired', 'canceled');

-- AlterTable
ALTER TABLE "UserBotAccess"
ADD COLUMN "status" "SubscriptionStatus" NOT NULL DEFAULT 'active',
ADD COLUMN "startsAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "expiresAt" TIMESTAMP(3),
ADD COLUMN "notes" TEXT;

-- Backfill
UPDATE "UserBotAccess"
SET "startsAt" = COALESCE("grantedAt", CURRENT_TIMESTAMP)
WHERE "startsAt" IS NULL;
