Files
junhong_cmp_fiber/migrations/000269_add_gateway_readonly_card.up.sql
邹进 5cf67b98de
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m36s
feat: 网关只读资产改为数据表,只读资产只允许查询类调用
- 新增 tb_gateway_readonly_card(卡 ICCID / 设备 IMEI)与开关 JUNHONG_GATEWAY_READONLY_ENABLED,
  替换环境变量名单 JUNHONG_GATEWAY_READONLY_ICCIDS
- 只读资产只放行查卡状态、查实名、查流量、查设备信息、查设备槽位、同步设备状态;
  停机、复机、限速、实名认证链接与设备写操作在网关出口本地拦截;查表失败按拦截;不缓存
- 测试环境部署开启只读模式;新增技术方案与清理顺序文档

Change: add-gateway-readonly-prod-import

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 17:55:52 +09:00

25 lines
1.8 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.
-- 网关只读资产表(add-gateway-readonly-prod-import)。
-- 测试环境导入生产卡与设备做流量计量验证时使用:开关 JUNHONG_GATEWAY_READONLY_ENABLED=true 时,
-- 表中的卡(ICCID)与设备(IMEI)只允许查询类网关调用(查卡状态、查实名、查流量、查设备信息、查设备槽位、同步设备状态),
-- 停机、复机、限速、实名认证链接与设备写操作在网关出口本地拦截。生产不配置该开关,不查本表。
-- 本迁移不写入数据;数据由测试环境导入脚本写入。
-- 撤除顺序见 docs/测试环境生产卡只读模式清理顺序.md:先处理导入资产 → 关开关并部署 → 新迁移删表。
-- 开关开启时删表会使所有非查询类调用失败(查表失败按拦截处理)。
CREATE TABLE tb_gateway_readonly_card (
id BIGSERIAL PRIMARY KEY,
identifier VARCHAR(64) NOT NULL,
identifier_type VARCHAR(16) NOT NULL,
source VARCHAR(64) NOT NULL DEFAULT '',
remark VARCHAR(255) NOT NULL DEFAULT '',
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
CONSTRAINT ck_gateway_readonly_card_type CHECK (identifier_type IN ('iccid', 'imei'))
);
CREATE UNIQUE INDEX uk_gateway_readonly_card_identifier ON tb_gateway_readonly_card (identifier);
COMMENT ON TABLE tb_gateway_readonly_card IS '网关只读资产:表中的卡与设备只允许查询类网关调用(测试环境导入生产数据验证用)';
COMMENT ON COLUMN tb_gateway_readonly_card.identifier IS '网关请求卡号(大写):卡为 ICCID,设备为 IMEI';
COMMENT ON COLUMN tb_gateway_readonly_card.identifier_type IS '卡号类型:iccid / imei';
COMMENT ON COLUMN tb_gateway_readonly_card.source IS '来源,如 prod_import_20261029';
COMMENT ON COLUMN tb_gateway_readonly_card.remark IS '备注';