-- CreateEnum
CREATE TYPE "InviteStatus" AS ENUM ('PENDING', 'ACCEPTED', 'EXPIRED', 'CANCELLED');

-- AlterTable: access-control lifecycle columns (all additive, nullable/defaulted)
ALTER TABLE "actuate_users" ADD COLUMN "suspendedAt" TIMESTAMP(3);
ALTER TABLE "actuate_users" ADD COLUMN "lockedAt" TIMESTAMP(3);
ALTER TABLE "actuate_users" ADD COLUMN "forcePasswordReset" BOOLEAN NOT NULL DEFAULT false;
ALTER TABLE "actuate_users" ADD COLUMN "mfaRequired" BOOLEAN NOT NULL DEFAULT false;
ALTER TABLE "actuate_users" ADD COLUMN "failedLoginCount" INTEGER NOT NULL DEFAULT 0;
ALTER TABLE "actuate_users" ADD COLUMN "lastActiveAt" TIMESTAMP(3);
ALTER TABLE "actuate_users" ADD COLUMN "invitedById" TEXT;
ALTER TABLE "actuate_users" ADD COLUMN "acceptedInviteAt" TIMESTAMP(3);

-- CreateTable
CREATE TABLE "actuate_invites" (
    "id" TEXT NOT NULL,
    "email" TEXT NOT NULL,
    "role" "UserRole" NOT NULL,
    "status" "InviteStatus" NOT NULL DEFAULT 'PENDING',
    "tokenHash" TEXT NOT NULL,
    "message" TEXT,
    "invitedByUserId" TEXT,
    "acceptedUserId" TEXT,
    "expiresAt" TIMESTAMP(3) NOT NULL,
    "acceptedAt" TIMESTAMP(3),
    "cancelledAt" TIMESTAMP(3),
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,

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

-- CreateIndex
CREATE INDEX "actuate_invites_email_idx" ON "actuate_invites"("email");

-- CreateIndex
CREATE INDEX "actuate_invites_tokenHash_idx" ON "actuate_invites"("tokenHash");

-- CreateIndex
CREATE INDEX "actuate_invites_status_idx" ON "actuate_invites"("status");
