-- 018_pivot_menu.sql
-- v0.7 (2026-05-07)
-- 통계 그룹에 "거래처×일자 매출 (피벗)" 메뉴 추가

BEGIN;

DO $$
BEGIN
  IF NOT EXISTS (SELECT 1 FROM menu_info WHERE objid = 9000504) THEN
    INSERT INTO menu_info (objid, menu_type, parent_obj_id, menu_name_kor, menu_name_eng,
                           seq, menu_url, status, system_name, regdate)
    VALUES (9000504, '1', 9000500, '거래처×일자 매출', 'Pivot Stats',
            8, '/m/admin/statistics/pivot', 'active', 'PMS', NOW());
  ELSE
    UPDATE menu_info
       SET parent_obj_id = 9000500,
           menu_name_kor = '거래처×일자 매출',
           menu_name_eng = 'Pivot Stats',
           menu_url      = '/m/admin/statistics/pivot',
           status        = 'active'
     WHERE objid = 9000504;
  END IF;
END $$;

COMMIT;
