-- ====================================================================
-- inventory_mgmt — 자재 마스터 (품번 + Location 단위 자재 정보)
-- ====================================================================
-- 출처: wace_plm 운영 DB 211.115.91.141:11133/waceplm (PG 16.8)
-- 추출일: 2026-05-15
-- 자식: inventory_mgmt_in (입고/이동 히스토리), inventory_mgmt_out (불출 라인)
-- ====================================================================

CREATE TABLE IF NOT EXISTS inventory_mgmt (
    objid                VARCHAR              NOT NULL,
    contract_objid       VARCHAR              NOT NULL,
    unit                 VARCHAR(100)         NOT NULL,
    part_objid           VARCHAR(100)         NOT NULL,
    cls_cd               VARCHAR(100),
    cau_cd               VARCHAR(100),
    qty                  VARCHAR(20),
    location             VARCHAR(20)          NOT NULL DEFAULT '',
    sub_location         VARCHAR(20)          NOT NULL DEFAULT '',
    reg_date             VARCHAR(10),
    price                VARCHAR(20),
    writer               VARCHAR(20),
    input_contract_objid VARCHAR,
    input_qty            VARCHAR,
    input_date           VARCHAR,
    assumption_user      VARCHAR,
    successor_user       VARCHAR,
    CONSTRAINT inventory_mgmt_pkey PRIMARY KEY (contract_objid, unit, part_objid)
);

CREATE INDEX IF NOT EXISTS inventory_mgmt_objid_idx     ON inventory_mgmt (objid);
CREATE INDEX IF NOT EXISTS inventory_mgmt_part_objid_idx ON inventory_mgmt (part_objid);
