-- CreateTable
CREATE TABLE "MemberHistory" (
    "id" TEXT NOT NULL,
    "memberId" TEXT NOT NULL,
    "treeId" TEXT NOT NULL,
    "version" INTEGER NOT NULL,
    "snapshot" JSONB NOT NULL,
    "changedBy" TEXT NOT NULL,
    "changedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "changeType" "Action" NOT NULL,
    "changes" JSONB,

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

-- CreateIndex
CREATE INDEX "MemberHistory_memberId_idx" ON "MemberHistory"("memberId");

-- CreateIndex
CREATE INDEX "MemberHistory_treeId_idx" ON "MemberHistory"("treeId");

-- CreateIndex
CREATE INDEX "MemberHistory_changedAt_idx" ON "MemberHistory"("changedAt");

-- CreateIndex
CREATE UNIQUE INDEX "MemberHistory_memberId_version_key" ON "MemberHistory"("memberId", "version");
