Repository navigation
fix: external_report_files has no foreign key (2.1.1) - #12
Merged
Merged
Conversation
Five new repositories, on PostgreSQL and MongoDB, for the api's report-reader imports: - externalReports (external_reports): one row per partner PDF, sourceSha256 unique per organisation, the ExtractedReport JSON as is, status, warnings - externalReportFiles (external_report_files): the PDF bytes, apart so lists never load them - externalSignatories (external_signatories): the partner signature registry; listForOrg is cached per organisation through the cache layer and cleared on every write - externalSignatures (external_signatures): the PNG per (organisation, PDF, signature) - reportProvenance (report_provenance): one per report, where its results came from Bytes go in as Uint8Array and come out as Buffer on both drivers. New tables and collections only; sync() creates them. Contract tests on both backends; TEST_BACKENDS=pg runs PostgreSQL only. docs/EXTERNAL-REPORTS.md describes the storage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018jBohmYiwjQLWmN2duiZcA
…ore its report) The api stores the PDF first and extracts it (inline or in a worker job whose payload carries only the file id); the external report then takes the file's id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018jBohmYiwjQLWmN2duiZcA
…ore its report) The api stores the PDF first and extracts it (inline or in a worker job whose payload carries only the file id); the external report then takes the file's id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018jBohmYiwjQLWmN2duiZcA
…to claude/project-thread-86xth5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018jBohmYiwjQLWmN2duiZcA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
In 2.1.0,
external_report_files.idwas a foreign key toexternal_reports. The api stores the partner PDF first and creates the external report with the file's id only after extraction. Extraction runs inline, or in a worker job whose payload carries just the file id. On PostgreSQL, every import therefore fails withexternal_report_files_id_fkey. This shows up on api#23's CI.Two separate pushes made 2.1.0 miss the fix: the fix (b30ee5e) landed on the branch after #11 had already merged.
src/pg/models.ts:idis now a plain UUID primary key with no foreign key. Mongo never had one.src/core/types.tsanddocs/EXTERNAL-REPORTS.md: document that the file is stored before its report.scripts/test.ts: a new contract check stores a PDF before its report exists, on both backends. This check would have caught the bug.TEST_BACKENDS=pg npm test: 100 passed, 0 failed. Mongo is not run locally; CI runs it.A database that already ran
sync()on 2.1.0 keeps the constraint, so drop it by hand:ALTER TABLE external_report_files DROP CONSTRAINT external_report_files_id_fkey;. None should exist yet, because the api has not been deployed with 2.1.0.Release: after merge, tag
v2.1.1.Generated by Claude Code