-- ============================================================
-- 내화실 품목 데이터 업데이트
-- 대상: tenant_id = 287 (경동), code = '80019'
-- 생성일: 2026-02-12
-- 변경: code, name, unit, attributes, options 업데이트
-- ============================================================

SET @TARGET_TENANT_ID = 287;

-- 안전장치
SET AUTOCOMMIT = 0;
START TRANSACTION;

-- 변경 전 확인
SELECT id, code, name, unit, attributes, options
FROM items
WHERE tenant_id = @TARGET_TENANT_ID AND code = '80019';

-- 업데이트
UPDATE items
SET
    code = '내화실-WY-MA12',
    name = '내화실',
    unit = '콘',
    attributes = JSON_SET(
        COALESCE(attributes, '{}'),
        '$.spec', 'WY-MA12'
    ),
    options = JSON_OBJECT(
        'lot_managed', TRUE,
        'consumption_method', 'manual',
        'production_source', 'purchased',
        'material', 'SUS316L + Para aramid'
    ),
    updated_at = NOW()
WHERE tenant_id = @TARGET_TENANT_ID
  AND code = '80019';

-- 변경 후 확인
SELECT id, code, name, unit, attributes, options
FROM items
WHERE tenant_id = @TARGET_TENANT_ID AND code = '내화실-WY-MA12';

-- 확인 후 COMMIT 또는 ROLLBACK
-- COMMIT;
-- ROLLBACK;