yunzerwebsiteallinone/sql/yz_platform_cursor_equipment_ip_log.sql
2026-06-22 11:24:08 +08:00

29 lines
2.0 KiB
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.

-- 设备 IP 登录日志表
-- 每次客户端调用 report / activateByCode 接口时,若携带 ipInfo则向本表插入一条记录
CREATE TABLE IF NOT EXISTS `yz_platform_cursor_equipment_ip_log` (
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
`equipment_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT '关联 yz_platform_cursor_equipment.id0 表示设备尚未创建时的记录',
`machine_code` VARCHAR(128) NOT NULL DEFAULT '' COMMENT '机器码(冗余,便于无 equipment_id 时查询)',
`source` VARCHAR(32) NOT NULL DEFAULT '' COMMENT '来源report / activateByCode',
-- ip-api.com 返回的原始字段
`status` VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'ip-api status',
`country` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '国家',
`country_code` VARCHAR(8) NOT NULL DEFAULT '' COMMENT '国家代码',
`region` VARCHAR(16) NOT NULL DEFAULT '' COMMENT '省/州代码',
`region_name` VARCHAR(128) NOT NULL DEFAULT '' COMMENT '省/州名称',
`city` VARCHAR(128) NOT NULL DEFAULT '' COMMENT '城市',
`zip` VARCHAR(32) NOT NULL DEFAULT '' COMMENT '邮编',
`lat` DOUBLE NOT NULL DEFAULT 0 COMMENT '纬度',
`lon` DOUBLE NOT NULL DEFAULT 0 COMMENT '经度',
`timezone` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '时区',
`isp` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'ISP 运营商',
`org` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '组织',
`as_info` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'AS 信息',
`query` VARCHAR(64) NOT NULL DEFAULT '' COMMENT '出口 IP 地址',
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '记录时间',
PRIMARY KEY (`id`),
KEY `idx_equipment_id` (`equipment_id`),
KEY `idx_machine_code` (`machine_code`),
KEY `idx_create_time` (`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='设备 IP 登录日志';