mirror of https://github.com/ghostfolio/ghostfolio
Browse Source
Co-authored-by: RobertgPatch <5817970+RobertgPatch@users.noreply.github.com> Agent-Logs-Url: https://github.com/RobertgPatch/portfolio-management/sessions/7c542bd9-8d19-4eb5-bf68-6debfe42d8afpull/6701/head
7 changed files with 141 additions and 48 deletions
@ -0,0 +1,93 @@ |
|||||
|
-- CreateEnum |
||||
|
CREATE TYPE "K1ImportStatus" AS ENUM ('PROCESSING', 'EXTRACTED', 'VERIFIED', 'CONFIRMED', 'CANCELLED', 'FAILED'); |
||||
|
|
||||
|
-- CreateTable |
||||
|
CREATE TABLE "K1ImportSession" ( |
||||
|
"id" TEXT NOT NULL, |
||||
|
"partnershipId" TEXT NOT NULL, |
||||
|
"userId" TEXT NOT NULL, |
||||
|
"status" "K1ImportStatus" NOT NULL DEFAULT 'PROCESSING', |
||||
|
"taxYear" INTEGER NOT NULL, |
||||
|
"fileName" TEXT NOT NULL, |
||||
|
"fileSize" INTEGER NOT NULL, |
||||
|
"extractionMethod" TEXT NOT NULL, |
||||
|
"rawExtraction" JSONB, |
||||
|
"verifiedData" JSONB, |
||||
|
"documentId" TEXT, |
||||
|
"kDocumentId" TEXT, |
||||
|
"errorMessage" TEXT, |
||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, |
||||
|
"updatedAt" TIMESTAMP(3) NOT NULL, |
||||
|
|
||||
|
CONSTRAINT "K1ImportSession_pkey" PRIMARY KEY ("id") |
||||
|
); |
||||
|
|
||||
|
-- CreateTable |
||||
|
CREATE TABLE "CellMapping" ( |
||||
|
"id" TEXT NOT NULL, |
||||
|
"partnershipId" TEXT, |
||||
|
"boxNumber" TEXT NOT NULL, |
||||
|
"label" TEXT NOT NULL, |
||||
|
"description" TEXT, |
||||
|
"cellType" TEXT NOT NULL DEFAULT 'number', |
||||
|
"isCustom" BOOLEAN NOT NULL DEFAULT false, |
||||
|
"isIgnored" BOOLEAN NOT NULL DEFAULT false, |
||||
|
"sortOrder" INTEGER NOT NULL, |
||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, |
||||
|
"updatedAt" TIMESTAMP(3) NOT NULL, |
||||
|
|
||||
|
CONSTRAINT "CellMapping_pkey" PRIMARY KEY ("id") |
||||
|
); |
||||
|
|
||||
|
-- CreateTable |
||||
|
CREATE TABLE "CellAggregationRule" ( |
||||
|
"id" TEXT NOT NULL, |
||||
|
"partnershipId" TEXT, |
||||
|
"name" TEXT NOT NULL, |
||||
|
"operation" TEXT NOT NULL DEFAULT 'SUM', |
||||
|
"sourceCells" JSONB NOT NULL, |
||||
|
"sortOrder" INTEGER NOT NULL, |
||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, |
||||
|
"updatedAt" TIMESTAMP(3) NOT NULL, |
||||
|
|
||||
|
CONSTRAINT "CellAggregationRule_pkey" PRIMARY KEY ("id") |
||||
|
); |
||||
|
|
||||
|
-- CreateIndex |
||||
|
CREATE INDEX "K1ImportSession_partnershipId_taxYear_idx" ON "K1ImportSession"("partnershipId", "taxYear"); |
||||
|
|
||||
|
-- CreateIndex |
||||
|
CREATE INDEX "K1ImportSession_userId_idx" ON "K1ImportSession"("userId"); |
||||
|
|
||||
|
-- CreateIndex |
||||
|
CREATE UNIQUE INDEX "K1ImportSession_kDocumentId_key" ON "K1ImportSession"("kDocumentId"); |
||||
|
|
||||
|
-- CreateIndex |
||||
|
CREATE INDEX "CellMapping_partnershipId_idx" ON "CellMapping"("partnershipId"); |
||||
|
|
||||
|
-- CreateIndex |
||||
|
CREATE UNIQUE INDEX "CellMapping_partnershipId_boxNumber_key" ON "CellMapping"("partnershipId", "boxNumber"); |
||||
|
|
||||
|
-- CreateIndex |
||||
|
CREATE INDEX "CellAggregationRule_partnershipId_idx" ON "CellAggregationRule"("partnershipId"); |
||||
|
|
||||
|
-- CreateIndex |
||||
|
CREATE UNIQUE INDEX "CellAggregationRule_partnershipId_name_key" ON "CellAggregationRule"("partnershipId", "name"); |
||||
|
|
||||
|
-- AddForeignKey |
||||
|
ALTER TABLE "K1ImportSession" ADD CONSTRAINT "K1ImportSession_partnershipId_fkey" FOREIGN KEY ("partnershipId") REFERENCES "Partnership"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
||||
|
|
||||
|
-- AddForeignKey |
||||
|
ALTER TABLE "K1ImportSession" ADD CONSTRAINT "K1ImportSession_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
||||
|
|
||||
|
-- AddForeignKey |
||||
|
ALTER TABLE "K1ImportSession" ADD CONSTRAINT "K1ImportSession_documentId_fkey" FOREIGN KEY ("documentId") REFERENCES "Document"("id") ON DELETE SET NULL ON UPDATE CASCADE; |
||||
|
|
||||
|
-- AddForeignKey |
||||
|
ALTER TABLE "K1ImportSession" ADD CONSTRAINT "K1ImportSession_kDocumentId_fkey" FOREIGN KEY ("kDocumentId") REFERENCES "KDocument"("id") ON DELETE SET NULL ON UPDATE CASCADE; |
||||
|
|
||||
|
-- AddForeignKey |
||||
|
ALTER TABLE "CellMapping" ADD CONSTRAINT "CellMapping_partnershipId_fkey" FOREIGN KEY ("partnershipId") REFERENCES "Partnership"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
||||
|
|
||||
|
-- AddForeignKey |
||||
|
ALTER TABLE "CellAggregationRule" ADD CONSTRAINT "CellAggregationRule_partnershipId_fkey" FOREIGN KEY ("partnershipId") REFERENCES "Partnership"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
||||
@ -1,21 +0,0 @@ |
|||||
import { PrismaClient } from '@prisma/client'; |
|
||||
const p = new PrismaClient(); |
|
||||
|
|
||||
// Delete all data in dependency order
|
|
||||
await p.access.deleteMany(); |
|
||||
await p.order.deleteMany(); |
|
||||
await p.accountBalance.deleteMany(); |
|
||||
await p.account.deleteMany(); |
|
||||
await p.symbolProfile.deleteMany(); |
|
||||
await p.marketData.deleteMany(); |
|
||||
await p.settings.deleteMany(); |
|
||||
await p.subscription.deleteMany(); |
|
||||
await p.authDevice.deleteMany(); |
|
||||
await p.analytics.deleteMany(); |
|
||||
await p.user.deleteMany(); |
|
||||
|
|
||||
console.log('All users deleted.'); |
|
||||
|
|
||||
const users = await p.user.findMany({ select: { id: true, role: true } }); |
|
||||
console.log('USERS after delete:', JSON.stringify(users)); |
|
||||
await p.$disconnect(); |
|
||||
Loading…
Reference in new issue