-- CreateTable
CREATE TABLE "IiosIdempotencyCommand" (
    "id" TEXT NOT NULL,
    "scopeId" TEXT,
    "commandName" TEXT NOT NULL,
    "idempotencyKey" TEXT NOT NULL,
    "schemaVersion" TEXT NOT NULL DEFAULT 'v1',
    "actorRefId" TEXT,
    "requestHash" TEXT NOT NULL,
    "responseHash" TEXT,
    "response" JSONB,
    "status" TEXT NOT NULL DEFAULT 'IN_FLIGHT',
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "completedAt" TIMESTAMP(3),

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

-- CreateIndex
CREATE INDEX "IiosIdempotencyCommand_scopeId_status_idx" ON "IiosIdempotencyCommand"("scopeId", "status");

-- CreateIndex
CREATE UNIQUE INDEX "IiosIdempotencyCommand_scopeId_commandName_idempotencyKey_key" ON "IiosIdempotencyCommand"("scopeId", "commandName", "idempotencyKey");
