docs: add unique constraint and search sanitization patterns#296
Merged
hoiekim merged 1 commit intohoiekim:mainfrom Mar 27, 2026
Merged
Conversation
moltboie
commented
Mar 15, 2026
Contributor
Author
moltboie
left a comment
There was a problem hiding this comment.
Self-Review
Discussion thread status:
- No prior thread.
Checked:
- Logic — Documents two patterns: (1) UNIQUE constraints for natural keys with ON CONFLICT upsert; (2)
ts_headlineoutput sanitization beforedangerouslySetInnerHTML. - Types — Docs only.
- Quality — Clear examples with bad/good patterns and references to implementing PRs.
- Maintainability — Migration script placement convention (
migrations/with numbered prefix) is well specified. - Security — The
ts_headlinesanitization note is important — allowing only<b>tags prevents XSS from PostgreSQL highlight output. - Tests — N/A.
- Blockers — None.
Issues found:
- None.
Confidence: High
Patterns extracted from recent merged PRs: - Data integrity constraints (PR hoiekim#143): enforce uniqueness at DB level with UNIQUE constraints and ON CONFLICT upserts, not just app logic - Search highlight sanitization (PR hoiekim#174): sanitize ts_headline output before dangerouslySetInnerHTML to prevent XSS via crafted content
a4dd67d to
938cfb3
Compare
hoiekim
approved these changes
Mar 27, 2026
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.
Add two patterns to DEVELOPMENT.md extracted from recent merged PRs:
Data Integrity Constraints
From PR #143 — enforce uniqueness at the database level with UNIQUE constraints and ON CONFLICT upserts. Application-level dedup is insufficient due to race conditions and concurrency. Includes guidance on manual migration scripts for DDL changes.
Search Highlight Sanitization
From PR #174 — sanitize
ts_headlineoutput beforedangerouslySetInnerHTMLto prevent XSS via crafted email content in search results.E2E Testing
Documentation-only change. Verified markdown renders correctly.