-- CreateTable
CREATE TABLE "review_tasks" (
    "id" TEXT NOT NULL,
    "user_id" TEXT NOT NULL,
    "file_name" TEXT NOT NULL,
    "file_size" INTEGER NOT NULL,
    "file_path" TEXT,
    "extracted_text" TEXT NOT NULL,
    "word_count" INTEGER,
    "status" TEXT NOT NULL DEFAULT 'pending',
    "editorial_review" JSONB,
    "methodology_review" JSONB,
    "overall_score" DOUBLE PRECISION,
    "model_used" TEXT,
    "started_at" TIMESTAMP(3),
    "completed_at" TIMESTAMP(3),
    "duration_seconds" INTEGER,
    "error_message" TEXT,
    "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updated_at" TIMESTAMP(3) NOT NULL,

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

-- CreateIndex
CREATE INDEX "review_tasks_user_id_idx" ON "review_tasks"("user_id");

-- CreateIndex
CREATE INDEX "review_tasks_status_idx" ON "review_tasks"("status");

-- CreateIndex
CREATE INDEX "review_tasks_created_at_idx" ON "review_tasks"("created_at");

-- AddForeignKey
ALTER TABLE "review_tasks" ADD CONSTRAINT "review_tasks_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
