Adds in Mantis features. Enabling automated downloading of Mantises into the internal database, browsing of them, and viewing of attachments (including .msg files).

Resolves #14
This commit is contained in:
Cameron Redmore 2025-04-25 23:31:50 +01:00
parent 0e77e310bd
commit 5268d6aecd
15 changed files with 1583 additions and 44 deletions

View file

@ -0,0 +1,50 @@
-- CreateTable
CREATE TABLE "MantisIssue" (
"id" SERIAL NOT NULL,
"title" TEXT NOT NULL,
"description" TEXT,
"reporter_id" TEXT NOT NULL,
"status" TEXT NOT NULL,
"priority" TEXT NOT NULL,
"severity" TEXT NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL,
CONSTRAINT "MantisIssue_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "MantisComment" (
"id" SERIAL NOT NULL,
"mantis_issue_id" INTEGER NOT NULL,
"sender_id" TEXT NOT NULL,
"comment" TEXT NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "MantisComment_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "MantisAttachment" (
"id" SERIAL NOT NULL,
"comment_id" INTEGER NOT NULL,
"filename" TEXT NOT NULL,
"url" TEXT NOT NULL,
"mime_type" TEXT,
"size" INTEGER,
"uploaded_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "MantisAttachment_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "MantisIssue" ADD CONSTRAINT "MantisIssue_reporter_id_fkey" FOREIGN KEY ("reporter_id") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "MantisComment" ADD CONSTRAINT "MantisComment_mantis_issue_id_fkey" FOREIGN KEY ("mantis_issue_id") REFERENCES "MantisIssue"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "MantisComment" ADD CONSTRAINT "MantisComment_sender_id_fkey" FOREIGN KEY ("sender_id") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "MantisAttachment" ADD CONSTRAINT "MantisAttachment_comment_id_fkey" FOREIGN KEY ("comment_id") REFERENCES "MantisComment"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View file

@ -0,0 +1,20 @@
/*
Warnings:
- You are about to drop the column `sender_id` on the `MantisComment` table. All the data in the column will be lost.
- You are about to drop the column `reporter_id` on the `MantisIssue` table. All the data in the column will be lost.
*/
-- DropForeignKey
ALTER TABLE "MantisComment" DROP CONSTRAINT "MantisComment_sender_id_fkey";
-- DropForeignKey
ALTER TABLE "MantisIssue" DROP CONSTRAINT "MantisIssue_reporter_id_fkey";
-- AlterTable
ALTER TABLE "MantisComment" DROP COLUMN "sender_id",
ADD COLUMN "sender_username" TEXT;
-- AlterTable
ALTER TABLE "MantisIssue" DROP COLUMN "reporter_id",
ADD COLUMN "reporter_username" TEXT;

View file

@ -137,3 +137,44 @@ model Log {
message String
meta Json? // Optional field for additional structured data
}
// --- Mantis Models Start ---
model MantisIssue {
id Int @id @default(autoincrement())
title String
description String?
reporterUsername String? @map("reporter_username")
status String
priority String
severity String
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
comments MantisComment[]
}
model MantisComment {
id Int @id @default(autoincrement())
mantisIssueId Int @map("mantis_issue_id")
senderUsername String? @map("sender_username")
comment String
createdAt DateTime @default(now()) @map("created_at")
mantisIssue MantisIssue @relation(fields: [mantisIssueId], references: [id], onDelete: Cascade)
attachments MantisAttachment[]
}
model MantisAttachment {
id Int @id @default(autoincrement())
commentId Int @map("comment_id")
filename String
url String // Store path or URL to the file
mimeType String? @map("mime_type")
size Int?
uploadedAt DateTime @default(now()) @map("uploaded_at")
comment MantisComment @relation(fields: [commentId], references: [id], onDelete: Cascade)
}
// --- Mantis Models End ---