Files
jcgl-dev/dev/sql/apt_rev01/33_duty_config_columns.sql
T
2026-11-14 13:01:21 +08:00

30 lines
1.4 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.
-- =============================================================================
-- 33 值班台测试配置增量列(R5 / 应用端/17)
--
-- 目的:SIP 分机可用号码段(如 1010-1050)需要可在值班台配置页录入,
-- 原先只存在于运维口头约定,`apt_ast_instance` 没有承载字段。
-- 约束:
-- 1) 只做幂等补列,不改既有列、不动任何 CHECK 约束;
-- 2) 分机号本身仍逐条登记在 `apt_sip_endpoint.extension`(号码不复用),
-- 号段只用于「录入时的取值范围校验与空闲号推荐」;
-- 3) 号段为空表示不限制(兼容既有部署)。
-- =============================================================================
SET NAMES utf8mb4;
SET SESSION sql_mode = 'STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION';
USE apt_rev01;
CALL apt_add_column_if_missing('apt_ast_instance', 'ext_pool_from',
'ext_pool_from VARCHAR(8) NULL COMMENT ''可用分机号段起(含),空=不限制''');
CALL apt_add_column_if_missing('apt_ast_instance', 'ext_pool_to',
'ext_pool_to VARCHAR(8) NULL COMMENT ''可用分机号段止(含),空=不限制''');
-- 校验 1:两列都存在
SELECT '=== 33. apt_ast_instance 号段列(应 2)===' AS section;
SELECT COUNT(*) AS ext_pool_columns
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'apt_ast_instance'
AND COLUMN_NAME IN ('ext_pool_from', 'ext_pool_to');