Conversation
…reference code sql move into repositories
…into repositories
… sql move into repositories
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 changed
Every SQL statement that ran outside a repository now lives in one, behavior-neutrally: statements in services, helpers, route files, the media worker's retention job and seams, and bare
*.drizzle.tshelper modules became named repository methods (or fragments exported by the repository that owns the tables). The copies of the Postgres unique-violation check and the SQL fragment type now have one home indb/. Nothing a user sees should change.Before you start
git diff --color-moved=dimmed-zebra --color-moved-ws=allow-indentation-change.Verify
Nothing new to verify: every step below is a regression check of a flow whose queries moved.
Regression
Deleting an account — [Web]
Requesting your data — [Web] [Mobile]
Photo reports and who can see them — [Web] [Mobile]
Guest reports — [Web]
Chat — [Web] [Mobile]
Hosting — [Web] [Mobile]
Admin — [Admin]
Findings addressed
Campaign PR 11 (SQL into repositories): BE-SQL-001, 003 to 007, 008 (reference codes), 009, 011, 013 (already fixed by #93), 014, 015 (fragment module), 016 to 018, 020 (repository method), 021 to 030, 032, 033, 034 (partly), 036, 037 (partly), 038 to 054; BE-ARCH-005 (SQL part).
Where the SQL went:
erasure-repository.drizzle.ts, called inside the same erasure transaction in the same order.retention-repository.drizzle.ts(exported to the worker as@civfix/api/retention-repo); the photo duplicate lookup is a worker-repository method.media-authorization-repository.drizzle.ts; the avatar claim and the upload lock aremedia-claim-repository.drizzle.ts.room-messages-repository), read watermarks, reply targets, mentions, reactions and attachments are repositories; user search has its own repository; report chat meta moved from the route into the report chat repository.db/client.tshelper.Decisions for the reviewer
writeAudit, the host standing module, three chat module paths, the block-pair fragment re-export, the social search wrappers, the forward-audit and upload-lock aliases); symbols still exported only because the transcript cases import them; the registration and organization repository part files that still carry a bare.drizzle.tsname.getDb()and build their own services, and the*Overridestest plumbing on the Fastify instance. The one statement still outside a repository is the job-queue depth read in the system health probe, which belongs behind the Jobs adapter.User-visible copy changes
None.
Tests changed
Only to follow moved paths or renamed symbols; no assertion changed.
erasure-scrubbed-columns.test.tsreads the donation-link statement from the erasure repository, where it now lives.host-export-csv.test.tsreads the roster and check-in queries from the export repository, with the slice markers following the new method names.media-public-served-key.test.ts: the served-key allow-list names the new avatar claim file instead of the old one (same exemption).report-content-routes.test.ts: a comment follows the renamed ownership check.retention-and-phash-pg.test.ts(worker integration): its header comment says where the retention deletes and the duplicate lookup now live.Verification
pnpm typecheck,pnpm lint,check:sqlclean; api unit suite by explicit path 428 files, 7290 passed, 3 skipped (the transcript suite grew to 939 cases); media-worker unit 300 passed, 2 failed (the known arm64 ffprobe helper issue fixed in Backend test safety net: SQL transcripts, CSRF pairing, authz and characterization tests #92).Staging checks
https://api.civfix.dev/readyzanswers ready (the readiness ping moved).Not covered
🤖 Generated with Claude Code