From fa2f768b8c781931683daec564ee726d9833a75a Mon Sep 17 00:00:00 2001 From: kadami <86646883+kadamidev@users.noreply.github.com> Date: Thu, 9 Jan 2025 15:07:45 +0000 Subject: [PATCH] delete existing PDRs before recreating --- desci-server/src/scripts/fixPublish.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/desci-server/src/scripts/fixPublish.ts b/desci-server/src/scripts/fixPublish.ts index a1374bb9..39aa99d9 100644 --- a/desci-server/src/scripts/fixPublish.ts +++ b/desci-server/src/scripts/fixPublish.ts @@ -3,7 +3,7 @@ import { logger as parentLogger } from '../logger.js'; import { redisClient } from '../redisClient.js'; import { publishSequencer, PublishServices } from '../services/PublishServices.js'; import { getIndexedResearchObjects } from '../theGraph.js'; -import { hexToCid } from '../utils.js'; +import { ensureUuidEndsWithDot, hexToCid } from '../utils.js'; import { invalidateByUuid } from './invalidate-redis-cache.js'; @@ -96,7 +96,12 @@ async function fixByNodeUuids({ cLogger.info(`[fixByNodeUuids] Fixing version: ${nodeVersIdx + 1}, with commitId: ${commitId}`); if (createIjPublishStatusEntry) { - // Add IJ publishStatus entry for the commitId + // Add IJ publishStatus entry for the commitId + remove existing PDRs + const node = await prisma.node.findUnique({ + where: { uuid: ensureUuidEndsWithDot(nodeUuid) }, + select: { id: true }, + }); + await prisma.publicDataReference.deleteMany({ where: { nodeId: node.id } }); await addIjPublishStatusEntry({ commitId, version: nodeVersIdx + 1, nodeUuid, manifestCid }); }