-- CreateEnum
CREATE TYPE "StrategicDiagnosticEvidenceSection" AS ENUM ('TECHNICAL', 'EXPERIENCE', 'ORGANIZATION', 'PUBLIC_PROCUREMENT');

-- AlterTable
ALTER TABLE "Organization"
ADD COLUMN "strategicDiagnosticData" JSONB,
ADD COLUMN "strategicDiagnosticScores" JSONB,
ADD COLUMN "strategicDiagnosticCompletedAt" TIMESTAMP(3);

-- CreateTable
CREATE TABLE "StrategicDiagnosticEvidenceDocument" (
    "id" TEXT NOT NULL,
    "organizationId" TEXT NOT NULL,
    "userId" TEXT NOT NULL,
    "section" "StrategicDiagnosticEvidenceSection" NOT NULL,
    "category" TEXT NOT NULL,
    "fileName" TEXT NOT NULL,
    "storedFileName" TEXT NOT NULL,
    "filePath" TEXT NOT NULL,
    "mimeType" TEXT NOT NULL,
    "sizeBytes" INTEGER NOT NULL,
    "checksumSha256" TEXT,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,

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

-- CreateIndex
CREATE INDEX "StrategicDiagnosticEvidenceDocument_organizationId_section_idx" ON "StrategicDiagnosticEvidenceDocument"("organizationId", "section");

-- CreateIndex
CREATE INDEX "StrategicDiagnosticEvidenceDocument_userId_section_idx" ON "StrategicDiagnosticEvidenceDocument"("userId", "section");

-- CreateIndex
CREATE INDEX "StrategicDiagnosticEvidenceDocument_createdAt_idx" ON "StrategicDiagnosticEvidenceDocument"("createdAt");

-- AddForeignKey
ALTER TABLE "StrategicDiagnosticEvidenceDocument" ADD CONSTRAINT "StrategicDiagnosticEvidenceDocument_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "StrategicDiagnosticEvidenceDocument" ADD CONSTRAINT "StrategicDiagnosticEvidenceDocument_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
