fix(import): company-scope the bank_file_imports dedup key (#925)
* fix(import): company-scope the bank_file_imports dedup key The bank_file_imports unique constraint was (user_id, file_hash), predating multi-tenancy: a user importing the same statement file into a second company hit an upsert that resolved onto the first company's row, which RLS rejected (42501). Widen it to (company_id, file_hash) - the swap 20260330130000 made for sie_imports but missed here - and drop the now-obsolete BANK_IMPORT_DUPLICATE_OTHER_COMPANY cross-company pre-check from the v1 route (the structured-error code stays for API compat). The migration was already applied to prod; committing it reconciles the orphan (prod schema_migrations had 20260707130000 with no matching repo file). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * docs(import): fix stale unique-constraint comment (CodeRabbit) The completion-update comment still described the old (user_id, file_hash) constraint; it is (company_id, file_hash) since 20260707130000. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
19cbb0094b
commit
63e05c4eec
@@ -79,7 +79,7 @@ export const POST = withRouteContext(
|
||||
status: 'processing',
|
||||
date_from: transactions.map((t) => t.date).sort()[0] || null,
|
||||
date_to: transactions.map((t) => t.date).sort().reverse()[0] || null,
|
||||
}, { onConflict: 'user_id,file_hash' })
|
||||
}, { onConflict: 'company_id,file_hash' })
|
||||
.select()
|
||||
.single()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user