Files
junhong_cmp_fiber/migrations/000090_device_fields_extension.up.sql
huang 42b884aaf8 feat(03-01): DB 迁移扩展设备字段 + 更新模型
- 新增迁移 000090:tb_device 扩展 5 个 Gateway sync-info 字段(online_status / last_online_time / software_version / switch_mode / last_gateway_sync_at)
- 新增迁移 000091:tb_device_sim_binding 新增 is_current 字段(当前使用卡标识)
- 更新 Device 模型新增对应 5 个字段
- 更新 DeviceSimBinding 模型新增 IsCurrent 字段
2026-03-28 11:31:16 +08:00

15 lines
939 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- 扩展 tb_device 设备表,新增 Gateway sync-info 同步的存储字段
-- 这些字段有"离线意义"设备下线后仍需保留最后状态非实时字段rssi/battery 等)不入库
ALTER TABLE tb_device
ADD COLUMN online_status INT NOT NULL DEFAULT 0,
ADD COLUMN last_online_time TIMESTAMP NULL,
ADD COLUMN software_version VARCHAR(100) NOT NULL DEFAULT '',
ADD COLUMN switch_mode VARCHAR(10) NOT NULL DEFAULT '0',
ADD COLUMN last_gateway_sync_at TIMESTAMP NULL;
COMMENT ON COLUMN tb_device.online_status IS '在线状态0未知1在线2离线';
COMMENT ON COLUMN tb_device.last_online_time IS '最后在线时间(来自 Gateway sync-info';
COMMENT ON COLUMN tb_device.software_version IS '固件版本号';
COMMENT ON COLUMN tb_device.switch_mode IS '切卡模式0=自动1=手动';
COMMENT ON COLUMN tb_device.last_gateway_sync_at IS '最后一次 sync-info 同步时间';