From 038539c191105caba0ae6ea9bdaa74526316ae80 Mon Sep 17 00:00:00 2001 From: jerick Date: Tue, 21 Apr 2026 21:02:54 -0400 Subject: [PATCH] Remove dedupeHash and duplicate skipping from CSV upload Drop dedupeHash field and unique constraint from Transaction model. Remove skipDuplicates from createMany. All rows in every upload are now inserted unconditionally. Co-Authored-By: Claude Sonnet 4.6 --- prisma/schema.prisma | 2 -- src/app/api/upload/route.ts | 2 -- src/lib/csv/normalizer.ts | 15 --------------- 3 files changed, 19 deletions(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index d3516cd..8013110 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -63,11 +63,9 @@ model Transaction { type TransactionType category String? notes String? - dedupeHash String createdAt DateTime @default(now()) updatedAt DateTime @updatedAt - @@unique([dedupeHash]) @@index([accountId, date]) @@index([date]) @@index([budgetId]) diff --git a/src/app/api/upload/route.ts b/src/app/api/upload/route.ts index 23913ba..50402ab 100644 --- a/src/app/api/upload/route.ts +++ b/src/app/api/upload/route.ts @@ -126,9 +126,7 @@ export async function POST(req: Request) { type: r.type, category: r.category ?? null, budgetId: r.budgetId, - dedupeHash: r.dedupeHash, })), - skipDuplicates: true, }) const skippedCount = normalized.length - importedCount diff --git a/src/lib/csv/normalizer.ts b/src/lib/csv/normalizer.ts index 4ddd5f1..20aeee5 100644 --- a/src/lib/csv/normalizer.ts +++ b/src/lib/csv/normalizer.ts @@ -1,4 +1,3 @@ -import { createHash } from 'crypto' import type { NormalizerConfig } from './bank-profiles' export interface NormalizedRow { @@ -7,7 +6,6 @@ export interface NormalizedRow { amountCents: number type: 'DEBIT' | 'CREDIT' category?: string - dedupeHash: string } export function parseCents(raw: string): number { @@ -51,18 +49,6 @@ function strategyB( return { amountCents: Math.abs(parseCents(creditRaw)), type: 'CREDIT' } } -function dedupeHash( - accountId: string, - date: Date, - description: string, - amountCents: number, -): string { - const dateStr = date.toISOString().split('T')[0] - return createHash('sha256') - .update(`${accountId}|${dateStr}|${description}|${amountCents}`) - .digest('hex') -} - export function normalizeRows( rows: Record[], accountId: string, @@ -100,7 +86,6 @@ export function normalizeRows( amountCents, type, category: rawCategory || undefined, - dedupeHash: dedupeHash(accountId, date, description, amountCents), }) } catch { // skip unparseable rows