ALTER TABLE `device_ledger`
    ADD COLUMN `is_iot_device` tinyint DEFAULT 0 COMMENT '是否为物联设备：0-否，1-是' AFTER `type`,
    ADD COLUMN `external_code` varchar(255) DEFAULT NULL COMMENT '外部编码' AFTER `is_iot_device`;

CREATE INDEX `idx_device_ledger_iot_external_code`
    ON `device_ledger` (`is_iot_device`, `external_code`);
