Insurance category, coverage type, and period baseline (#120)#121
Merged
Conversation
Slice B of the contract/insurance/education classification work. Introduces a classification + period model on the insurance domain so the operator can describe an item as PRIMARY (12개월 메인) or ADDON (시간제/원데이 등 부가), pin a coverage type aligned with the 유상운송 product line, and stamp each rider-insurance link with its own starts_at / ends_at lifecycle plus a no-FK pointer to the rider-bike contract that triggered the insurance. Schema (Flyway V8): - insurance_items: category (PRIMARY|ADDON), coverage_type (GENERAL_PAID_TRANSPORT|LIABILITY_PAID_TRANSPORT|HOURLY|ONE_DAY|OTHER), default_duration_unit, default_duration_value, with check constraints + category active index. - rider_insurances: starts_at, ends_at, rider_bike_contract_id, with period check constraint and (rider_id, starts_at, ends_at) period index plus contract pointer index. - 4-row seed: 유상운송종합/책임 (PRIMARY × MONTH × 12) + 시간제 (ADDON × HOUR × 1) + 원데이 (ADDON × DAY × 1). Deterministic UUIDs (`22222222-…`) so Slice A's contract_templates.default_insurance_item_id pointer can resolve them in a follow-up slice. - Existing rows default to category=PRIMARY; the unique policy on (rider_id, insurance_item_id) WHERE deleted_at IS NULL stays untouched in this slice. ADDON multi-issue (issue per starts_at) needs a follow-up partial-unique change and is intentionally deferred. API: - InsuranceItemCreateRequest accepts both legacy (name/description/enabled) and structured (category + coverageType + defaultDuration) shapes. - InsuranceItemUpdateRequest mirrors the structured fields with per-field provided flags. - RiderInsuranceCreateRequest/UpdateRequest add startsAt, endsAt, riderBikeContractId. - Read response DTOs expose all new fields. - Service-layer validation: rejects half-supplied default durations (`durationUnit`/`durationValue` must come together), enforces endsAt > startsAt on rider-insurance links, keeps the existing ResourceNotFound / ReferenceNotFound / DUPLICATE_ACTIVE_RESOURCE / INVALID STATE_TRANSITION error contract. Tests: - New InsuranceClassificationApiTests covers V8 seed presence, structured create, legacy compatibility, half-duration rejection, classification PATCH, period rejection (endsAt before startsAt), and the contract-pointer pass-through on rider-insurance create. - Existing InsuranceItemCommandApiContractTests / RiderInsurance flows stay green via the legacy create paths on the request DTOs. Trace: - Target issue: #120 - Change-control issue: EVNSolution/clever-change-control#114 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 8, 2026
This was referenced May 8, 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.
Summary
insurance_items에 분류(PRIMARY/ADDON), 보장유형(유상운송종합/책임/시간제/원데이/기타), 기본 기간(unit + value) 컬럼 추가.rider_insurances에starts_at/ends_at/rider_bike_contract_id추가 — 보험 라이프사이클 + 계약 연결 표현 가능.endsAt > startsAt강제, 기존 unique 정책 유지.Trace
default_insurance_item_idpointer)Scope
Backend-only. Slice A 와 같은 패턴이며 보험 도메인만 건드림. 기존 unique 정책은 유지하고 ADDON 다중 발급(시작시점별 unique)은 후속 슬라이스로 분리.
Included:
Excluded:
Validation
Test plan
Concurrent work gate
Note
Slice A (PR #119) 와 파일 충돌 0 — 다른 도메인. dev 머지 순서 무관. 향후 Slice D 에서 contract template + insurance item 자동 발급 로직을 도입할 때 두 슬라이스가 모두 머지된 상태가 전제.