Files
tessera-ctl/apps/api/prisma/migrations/20260721120000_add_tender_radar/migration.sql
T
schalli 713b1eb748 feat(10-01): add Tender/TenderSourcePollConfig models + ingestion packages
- Install fast-xml-parser, adm-zip, csv-parse in @tessera/api
- Add global Tender model (no tenantId — D-03 platform-global data)
- Add singleton TenderSourcePollConfig (sourceType @unique)
- Handwritten additive migration for both tables
- Regenerate Prisma client
2026-07-21 10:33:24 +02:00

55 lines
1.7 KiB
SQL

-- CreateTable
CREATE TABLE IF NOT EXISTS "Tender" (
"id" TEXT NOT NULL,
"sourcePortal" TEXT NOT NULL,
"sourceNoticeId" TEXT NOT NULL,
"ocid" TEXT,
"dedupKey" TEXT NOT NULL,
"title" TEXT NOT NULL,
"buyerName" TEXT,
"cpvCodes" TEXT[] DEFAULT ARRAY[]::TEXT[],
"region" TEXT,
"plz" TEXT,
"bundesland" TEXT,
"deadlineAt" TIMESTAMP(3),
"estimatedValue" DECIMAL(14,2),
"procedureType" TEXT,
"status" TEXT NOT NULL DEFAULT 'active',
"sourceUrl" TEXT,
"contentHash" TEXT NOT NULL,
"rawPayload" JSONB,
"publishedAt" TIMESTAMP(3) NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "Tender_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE IF NOT EXISTS "TenderSourcePollConfig" (
"id" TEXT NOT NULL,
"sourceType" TEXT NOT NULL,
"pollIntervalMin" INTEGER NOT NULL DEFAULT 60,
"isActive" BOOLEAN NOT NULL DEFAULT false,
"lastIngestedDay" TIMESTAMP(3),
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "TenderSourcePollConfig_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX IF NOT EXISTS "Tender_dedupKey_key" ON "Tender"("dedupKey");
-- CreateIndex
CREATE INDEX IF NOT EXISTS "Tender_status_idx" ON "Tender"("status");
-- CreateIndex
CREATE INDEX IF NOT EXISTS "Tender_deadlineAt_idx" ON "Tender"("deadlineAt");
-- CreateIndex
CREATE INDEX IF NOT EXISTS "Tender_publishedAt_idx" ON "Tender"("publishedAt");
-- CreateIndex
CREATE UNIQUE INDEX IF NOT EXISTS "TenderSourcePollConfig_sourceType_key" ON "TenderSourcePollConfig"("sourceType");