Files
junhong_cmp_fiber/migrations/000046_create_tb_polling_config.up.sql
huang 931e140e8e
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 6m35s
feat: 实现 IoT 卡轮询系统(支持千万级卡规模)
实现功能:
- 实名状态检查轮询(可配置间隔)
- 卡流量检查轮询(支持跨月流量追踪)
- 套餐检查与超额自动停机
- 分布式并发控制(Redis 信号量)
- 手动触发轮询(单卡/批量/条件筛选)
- 数据清理配置与执行
- 告警规则与历史记录
- 实时监控统计(队列/性能/并发)

性能优化:
- Redis 缓存卡信息,减少 DB 查询
- Pipeline 批量写入 Redis
- 异步流量记录写入
- 渐进式初始化(10万卡/批)

压测工具(scripts/benchmark/):
- Mock Gateway 模拟上游服务
- 测试卡生成器
- 配置初始化脚本
- 实时监控脚本

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 17:32:44 +08:00

45 lines
2.1 KiB
SQL
Raw Permalink 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.
-- 轮询配置表
-- 先删除旧表(如果存在)
DROP TABLE IF EXISTS tb_polling_config CASCADE;
CREATE TABLE tb_polling_config (
id BIGSERIAL PRIMARY KEY,
config_name VARCHAR(100) NOT NULL,
card_condition VARCHAR(50),
card_category VARCHAR(50),
carrier_id BIGINT,
priority INT NOT NULL DEFAULT 100,
realname_check_interval INT,
carddata_check_interval INT,
package_check_interval INT,
status SMALLINT NOT NULL DEFAULT 1,
description TEXT,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
created_by BIGINT,
updated_by BIGINT
);
-- 索引
CREATE INDEX idx_polling_config_status_priority ON tb_polling_config(status, priority);
CREATE INDEX idx_polling_config_carrier_id ON tb_polling_config(carrier_id);
-- 表注释
COMMENT ON TABLE tb_polling_config IS '轮询配置表 - 定义不同条件下的卡轮询策略';
-- 列注释
COMMENT ON COLUMN tb_polling_config.config_name IS '配置名称';
COMMENT ON COLUMN tb_polling_config.card_condition IS '卡状态条件not_real_name/real_name/activated/suspended';
COMMENT ON COLUMN tb_polling_config.card_category IS '卡业务类型normal/industry';
COMMENT ON COLUMN tb_polling_config.carrier_id IS '运营商ID可选精确匹配';
COMMENT ON COLUMN tb_polling_config.priority IS '优先级(数字越小优先级越高)';
COMMENT ON COLUMN tb_polling_config.realname_check_interval IS '实名检查间隔NULL表示不检查';
COMMENT ON COLUMN tb_polling_config.carddata_check_interval IS '流量检查间隔NULL表示不检查';
COMMENT ON COLUMN tb_polling_config.package_check_interval IS '套餐检查间隔NULL表示不检查';
COMMENT ON COLUMN tb_polling_config.status IS '状态0-禁用1-启用';
COMMENT ON COLUMN tb_polling_config.description IS '配置说明';
COMMENT ON COLUMN tb_polling_config.created_at IS '创建时间';
COMMENT ON COLUMN tb_polling_config.updated_at IS '更新时间';
COMMENT ON COLUMN tb_polling_config.created_by IS '创建人ID';
COMMENT ON COLUMN tb_polling_config.updated_by IS '更新人ID';