feat: 분급 비율 회차(월) 단위 등록 지원 (V81)
- installment_ratio.plan_month INT NULL 컬럼 추가 - NULL = 연 단위(연차 합계, 기존 동작) - 1~12 = 해당 회차(월) 단위 비율 - UNIQUE 재정의: NULLS NOT DISTINCT (product_category, plan_year, plan_month, effective_from) - InstallmentPlanGenerator: planMonth=NULL이면 1, NOT NULL이면 그대로 사용해 settle_month 계산 - 분급비율 화면: 회차(월) 컬럼·입력 추가, "(연차-1)*12+월" 통합 회차 표기
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
-- V81: installment_ratio 에 plan_month(회차/월) 컬럼 추가.
|
||||
-- NULL = 연 단위 (기존 동작, 1차년도 등 합계 비율)
|
||||
-- 1~12 = 해당 회차(월) 단위 비율
|
||||
--
|
||||
-- 기존 7건(NULL) 은 그대로 두고 새 UNIQUE 키만 재정의한다.
|
||||
|
||||
ALTER TABLE installment_ratio
|
||||
ADD COLUMN IF NOT EXISTS plan_month INT
|
||||
CHECK (plan_month IS NULL OR (plan_month BETWEEN 1 AND 12));
|
||||
|
||||
COMMENT ON COLUMN installment_ratio.plan_month IS
|
||||
'NULL=연 단위(연차 합계), 1~12=해당 회차(월) 단위 비율';
|
||||
|
||||
-- 기존 UNIQUE (product_category, plan_year, effective_from) 제거 후
|
||||
-- plan_month 포함 UNIQUE 재정의. NULL 도 동일하게 취급되어야 하므로 NULLS NOT DISTINCT 사용 (PG15+).
|
||||
ALTER TABLE installment_ratio
|
||||
DROP CONSTRAINT IF EXISTS installment_ratio_product_category_plan_year_effective_fr_key;
|
||||
|
||||
ALTER TABLE installment_ratio
|
||||
ADD CONSTRAINT installment_ratio_unique
|
||||
UNIQUE NULLS NOT DISTINCT (product_category, plan_year, plan_month, effective_from);
|
||||
|
||||
-- 조회 인덱스 보강 — 특정 카테고리·연차·회차의 활성 비율 빠른 조회
|
||||
DROP INDEX IF EXISTS idx_ir_category_year;
|
||||
CREATE INDEX IF NOT EXISTS idx_ir_category_year_month
|
||||
ON installment_ratio(product_category, plan_year, plan_month, effective_from DESC);
|
||||
Reference in New Issue
Block a user