refactor: 대상당 활성 공유 링크는 1개 - #169
Merged
Merged
Conversation
대상 구성은 조인 테이블 둘에 흩어져 있어 유니크 제약을 직접 걸 수 없다. 정렬된 식별자 목록의 해시를 비정규화해 shares 한 테이블에서 비교한다.
발급할 때마다 링크가 쌓여 살아있는 공개 URL 수에 상한이 없었다. 토큰 원문을 저장하지 않아 기존 링크의 URL 을 다시 내려줄 수 없으므로 재사용이 아니라 교체다.
This was referenced Sep 3, 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.
관련 이슈
변경 내용
shares.target_hash추가 +UNIQUE (user_id, target_hash) WHERE status = 'ACTIVE'(V31)Share.targetKey()로 도메인에 둠 (선택 순서 무관)작업 목적
공유 버튼을 누를 때마다 새 링크가 생기고 이전 링크가 계속 살아 있어, 살아있는 공개 URL 수에
상한이 없었다. 시술기록 한 건에 활성 링크가 7 개까지 쌓인 사례가 있다. 공유를 다시 만드는
행위를 "이전 링크는 그만 쓰겠다" 로 정의해 링크 수를 대상 가짓수로 유계로 만든다.
테스트 방법
애플리케이션이 만드는 해시와 V31 백필이 만드는 해시가 같은지 실제 스키마 위에서 대조한다
(
computesTheSameTargetHashAsTheBackfill). 이 둘이 어긋나면 중복 제거가 조용히 무력해진다.체크리스트
기타 사항
나머지를 폐기한다. 현재 운영 기준 활성 링크 27 개 중 13 개가 닫히고 14 개가 남는다.
이미 배포된 링크가 열리지 않게 되므로 배포 시점을 알고 있어야 한다.
그런 흐름이 없고, 오래된 링크가 계속 열려 있는 위험이 더 크다고 판단했다.
expires_in_days에 큰 값을 넣으면 사실상 만료되지 않는다)는이 PR 의 범위가 아니다. 별도 이슈로 다룬다.