Files
jongryangje/writable/database/packaging_unit_tables.sql
javamon1174 acc9e4741e P2-05/06 포장 단위 관리 CRUD + 이력 + 기간별 조회
- packaging_unit, packaging_unit_history 테이블 생성
- PackagingUnitModel, PackagingUnitHistoryModel
- PackagingUnit 컨트롤러 (목록/등록/수정/삭제/이력)
- 박스당팩수 x 팩당낱장수 = 총낱장수 자동 계산
- 변경 시 자동 이력 기록
- E2E 테스트 3개 전체 통과

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 16:32:55 +09:00

35 lines
1.7 KiB
SQL

-- ============================================
-- 포장 단위 관리 테이블 (P2-05, P2-06)
-- ============================================
CREATE TABLE IF NOT EXISTS `packaging_unit` (
`pu_idx` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`pu_lg_idx` INT UNSIGNED NOT NULL COMMENT '지자체 FK',
`pu_bag_code` VARCHAR(50) NOT NULL COMMENT '봉투코드(code_detail cd_code, ck=O)',
`pu_bag_name` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '봉투명(스냅샷)',
`pu_box_per_pack` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '박스당 팩 수',
`pu_pack_per_sheet` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '팩당 낱장 수',
`pu_total_per_box` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '1박스당 총 낱장 수',
`pu_start_date` DATE NOT NULL,
`pu_end_date` DATE NULL DEFAULT NULL,
`pu_state` TINYINT UNSIGNED NOT NULL DEFAULT 1,
`pu_regdate` DATETIME NOT NULL,
`pu_moddate` DATETIME NULL DEFAULT NULL,
`pu_reg_mb_idx` INT UNSIGNED NULL,
PRIMARY KEY (`pu_idx`),
KEY `idx_pu_lg_bag` (`pu_lg_idx`, `pu_bag_code`),
KEY `idx_pu_dates` (`pu_start_date`, `pu_end_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='포장 단위';
CREATE TABLE IF NOT EXISTS `packaging_unit_history` (
`puh_idx` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`puh_pu_idx` INT UNSIGNED NOT NULL,
`puh_field` VARCHAR(30) NOT NULL,
`puh_old_value` VARCHAR(100) NOT NULL DEFAULT '',
`puh_new_value` VARCHAR(100) NOT NULL DEFAULT '',
`puh_changed_at` DATETIME NOT NULL,
`puh_changed_by` INT UNSIGNED NULL,
PRIMARY KEY (`puh_idx`),
KEY `idx_puh_pu_idx` (`puh_pu_idx`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='포장 단위 변경 이력';