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 <noreply@anthropic.com>
This commit is contained in:
2026-04-21 21:02:54 -04:00
parent decfb19ec6
commit 038539c191
3 changed files with 0 additions and 19 deletions

View File

@@ -63,11 +63,9 @@ model Transaction {
type TransactionType type TransactionType
category String? category String?
notes String? notes String?
dedupeHash String
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
@@unique([dedupeHash])
@@index([accountId, date]) @@index([accountId, date])
@@index([date]) @@index([date])
@@index([budgetId]) @@index([budgetId])

View File

@@ -126,9 +126,7 @@ export async function POST(req: Request) {
type: r.type, type: r.type,
category: r.category ?? null, category: r.category ?? null,
budgetId: r.budgetId, budgetId: r.budgetId,
dedupeHash: r.dedupeHash,
})), })),
skipDuplicates: true,
}) })
const skippedCount = normalized.length - importedCount const skippedCount = normalized.length - importedCount

View File

@@ -1,4 +1,3 @@
import { createHash } from 'crypto'
import type { NormalizerConfig } from './bank-profiles' import type { NormalizerConfig } from './bank-profiles'
export interface NormalizedRow { export interface NormalizedRow {
@@ -7,7 +6,6 @@ export interface NormalizedRow {
amountCents: number amountCents: number
type: 'DEBIT' | 'CREDIT' type: 'DEBIT' | 'CREDIT'
category?: string category?: string
dedupeHash: string
} }
export function parseCents(raw: string): number { export function parseCents(raw: string): number {
@@ -51,18 +49,6 @@ function strategyB(
return { amountCents: Math.abs(parseCents(creditRaw)), type: 'CREDIT' } 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( export function normalizeRows(
rows: Record<string, string>[], rows: Record<string, string>[],
accountId: string, accountId: string,
@@ -100,7 +86,6 @@ export function normalizeRows(
amountCents, amountCents,
type, type,
category: rawCategory || undefined, category: rawCategory || undefined,
dedupeHash: dedupeHash(accountId, date, description, amountCents),
}) })
} catch { } catch {
// skip unparseable rows // skip unparseable rows