addd TG integration

This commit is contained in:
xCyanGrizzly
2026-03-02 11:57:17 +01:00
parent b427193d17
commit 4d0df6b1a4
35 changed files with 4436 additions and 242 deletions

View File

@@ -0,0 +1,30 @@
-- CreateEnum
CREATE TYPE "FetchStatus" AS ENUM ('PENDING', 'IN_PROGRESS', 'COMPLETED', 'FAILED');
-- CreateTable
CREATE TABLE "global_settings" (
"key" VARCHAR(64) NOT NULL,
"value" TEXT NOT NULL,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "global_settings_pkey" PRIMARY KEY ("key")
);
-- CreateTable
CREATE TABLE "channel_fetch_requests" (
"id" TEXT NOT NULL,
"accountId" TEXT NOT NULL,
"status" "FetchStatus" NOT NULL DEFAULT 'PENDING',
"resultJson" TEXT,
"error" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "channel_fetch_requests_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "channel_fetch_requests_accountId_status_idx" ON "channel_fetch_requests"("accountId", "status");
-- AddForeignKey
ALTER TABLE "channel_fetch_requests" ADD CONSTRAINT "channel_fetch_requests_accountId_fkey" FOREIGN KEY ("accountId") REFERENCES "telegram_accounts"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@@ -384,6 +384,13 @@ enum IngestionStatus {
CANCELLED
}
enum FetchStatus {
PENDING
IN_PROGRESS
COMPLETED
FAILED
}
model TelegramAccount {
id String @id @default(cuid())
phone String @unique
@@ -397,6 +404,7 @@ model TelegramAccount {
channelMaps AccountChannelMap[]
ingestionRuns IngestionRun[]
fetchRequests ChannelFetchRequest[]
@@index([isActive])
@@map("telegram_accounts")
@@ -535,3 +543,26 @@ model TopicProgress {
@@index([accountChannelMapId])
@@map("topic_progress")
}
model GlobalSetting {
key String @id @db.VarChar(64)
value String @db.Text
updatedAt DateTime @updatedAt
@@map("global_settings")
}
model ChannelFetchRequest {
id String @id @default(cuid())
accountId String
status FetchStatus @default(PENDING)
resultJson String? @db.Text
error String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
account TelegramAccount @relation(fields: [accountId], references: [id], onDelete: Cascade)
@@index([accountId, status])
@@map("channel_fetch_requests")
}