-- Obsidian Wrapped — агрегаты прогона (без имён/текстов заметок)
CREATE TABLE "WrappedRun" (
    "id" TEXT NOT NULL,
    "userId" TEXT NOT NULL,
    "period" TEXT NOT NULL DEFAULT 'year',
    "noteCount" INTEGER NOT NULL,
    "linkCount" INTEGER NOT NULL,
    "tagCount" INTEGER NOT NULL,
    "topTag" TEXT,
    "archetype" TEXT,
    "score" INTEGER NOT NULL DEFAULT 0,
    "shareToken" TEXT NOT NULL,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,
    CONSTRAINT "WrappedRun_pkey" PRIMARY KEY ("id")
);

CREATE UNIQUE INDEX "WrappedRun_shareToken_key" ON "WrappedRun"("shareToken");
CREATE INDEX "WrappedRun_userId_idx" ON "WrappedRun"("userId");

ALTER TABLE "WrappedRun" ADD CONSTRAINT "WrappedRun_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
