From 97497d34ad0393417e26e0c2d6b748e5f62c4cc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=B3=E9=A9=B9=20=E4=B8=87?= Date: Fri, 11 Nov 2022 15:55:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0gbsip=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E7=BB=93=E6=9E=84=E3=80=82=E6=B3=A8=E6=84=8F=EF=BC=9A?= =?UTF-8?q?=E4=BC=9A=E5=88=A0=E9=99=A4=E4=B9=8B=E5=89=8D=E8=80=81=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E7=9A=84=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/mysql/docker_mysql_create_table.sh | 30 ++++++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/script/mysql/docker_mysql_create_table.sh b/script/mysql/docker_mysql_create_table.sh index cb669a0..7be9871 100644 --- a/script/mysql/docker_mysql_create_table.sh +++ b/script/mysql/docker_mysql_create_table.sh @@ -76,12 +76,23 @@ fi ####GBS mysql_gbs_dbname="gbs" + +###########移除旧版gbs############2022.11.11 +sql_table_is_exits="USE $mysql_gbs_dbname; +select 1 FROM information_schema.TABLES WHERE table_name ='T_SuperiorChannel';" +host=$(mysql -u$mysql_root_user_name -p$mysql_root_user_pwd -P$mysql_port -e"$sql_table_is_exits") +if [ ! -n "$host" ] ;then + echo "移除旧版gbs...." + mysql -u$mysql_root_user_name -p$mysql_root_user_pwd -P$mysql_port -e"DROP DATABASE $mysql_gbs_dbname;" +fi +########################################## + #创建GBS数据库 sql_create_database="CREATE DATABASE IF NOT EXISTS $mysql_gbs_dbname" mysql -u$mysql_root_user_name -p$mysql_root_user_pwd -P$mysql_port -e"$sql_create_database" #创建表 -sql_create_table="USE $mysql_gbs_dbname; +sql_create_table="set character_set_results=utf8; set character_set_client=utf8; set collation_connection= utf8_general_ci; USE $mysql_gbs_dbname; CREATE TABLE IF NOT EXISTS T_Catalog ( ChannelID varchar(50) NOT NULL COMMENT 'CatalogID', DeviceID varchar(50) NOT NULL COMMENT '设备ID', @@ -109,7 +120,7 @@ CREATE TABLE IF NOT EXISTS T_Catalog ( Longitude double NOT NULL COMMENT '经度', Latitude double NOT NULL COMMENT '纬度', RemoteEP varchar(50) NOT NULL DEFAULT '' COMMENT '远程设备终结点', - Online bit(1) NOT NULL DEFAULT b'1' COMMENT '在线状态', + Online bit(1) NOT NULL COMMENT '在线状态', OnlineTime timestamp NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '上次上线时间', OfflineTime timestamp NULL DEFAULT NULL COMMENT '离线时间', PRIMARY KEY (ChannelID,DeviceID) @@ -154,11 +165,21 @@ CREATE TABLE IF NOT EXISTS T_Event ( PRIMARY KEY (RowID) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -CREATE TABLE IF NOT EXISTS T_SuperiorInfo ( +CREATE TABLE IF NOT EXISTS T_SuperiorChannel ( + SuperiorID varchar(50) NOT NULL COMMENT '上级ID', + CustomChannelID varchar(50) NOT NULL COMMENT '自定义通道ID', + DeviceID varchar(50) NOT NULL COMMENT '设备ID', + ChannelID varchar(50) NOT NULL COMMENT 'CatalogID', Enable bit(1) NOT NULL COMMENT '启用', + PRIMARY KEY (SuperiorID,CustomChannelID) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS T_SuperiorInfo ( ID varchar(50) NOT NULL COMMENT '唯一ID', + Enable bit(1) NOT NULL COMMENT '启用', Name varchar(50) NOT NULL COMMENT '名称', ServerID varchar(50) NOT NULL COMMENT '上级国标编码', + ServerRealm varchar(50) NOT NULL COMMENT '服务域', Server varchar(50) NOT NULL COMMENT '上级IP/域名', ServerPort int(11) NOT NULL COMMENT '上级端口', ClientID varchar(50) NOT NULL COMMENT '本地SIP国标编码', @@ -169,7 +190,8 @@ CREATE TABLE IF NOT EXISTS T_SuperiorInfo ( RegSec int(11) NOT NULL COMMENT '注册间隔', HeartSec int(11) NOT NULL COMMENT '心跳周期', HeartTimeoutTimes int(11) NOT NULL COMMENT '最大心跳超时次数', - UseTcp bit(1) NOT NULL COMMENT 'TCP/UDP' + UseTcp bit(1) NOT NULL COMMENT 'TCP/UDP', + PRIMARY KEY (ID) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS T_UserInfo (