修改SQL对比算法

This commit is contained in:
GoEdgeLab
2020-11-16 23:30:47 +08:00
parent 8f92d0c518
commit 7b7e5cf982
21 changed files with 588 additions and 1512 deletions

View File

@@ -41,6 +41,10 @@ function build() {
cp $ROOT"/../../EdgeNode/dist/edge-node-linux-${arch}-v${NodeVersion}.zip" $ROOT/deploy/
done
# build sql
echo "building sql ..."
${ROOT}/sql.sh
# copy files
echo "copying ..."
if [ ! -d $DIST ]; then

3
build/sql.sh Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env bash
go run `dirname $0`/../../cmd/sql-dump/main.go -dir=`dirname $0`

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env bash
go run `dirname $0`/../../cmd/sql-generate/main.go -dir=`dirname $0`

View File

@@ -1,638 +0,0 @@
CREATE TABLE `edgeAPINodes` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',
`clusterId` int(11) unsigned DEFAULT '0' COMMENT '专用集群ID',
`uniqueId` varchar(32) DEFAULT NULL COMMENT '唯一ID',
`secret` varchar(32) DEFAULT NULL COMMENT '密钥',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`description` varchar(1024) DEFAULT NULL COMMENT '描述',
`http` json DEFAULT NULL COMMENT '监听的HTTP配置',
`https` json DEFAULT NULL COMMENT '监听的HTTPS配置',
`accessAddrs` json DEFAULT NULL COMMENT '外部访问地址',
`order` int(11) unsigned DEFAULT '0' COMMENT '排序',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
`weight` int(11) unsigned DEFAULT '0' COMMENT '权重',
`status` json DEFAULT NULL COMMENT '运行状态',
PRIMARY KEY (`id`),
UNIQUE KEY `uniqueId` (`uniqueId`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='API节点';
CREATE TABLE `edgeAPITokens` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`nodeId` varchar(32) DEFAULT NULL COMMENT '节点ID',
`secret` varchar(255) DEFAULT NULL COMMENT '节点密钥',
`role` varchar(64) DEFAULT NULL COMMENT '节点角色',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
PRIMARY KEY (`id`),
KEY `nodeId` (`nodeId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='API令牌管理';
CREATE TABLE `edgeAdmins` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`username` varchar(64) DEFAULT NULL COMMENT '用户名',
`password` varchar(32) DEFAULT NULL COMMENT '密码',
`fullname` varchar(64) DEFAULT NULL COMMENT '全名',
`isSuper` tinyint(1) unsigned DEFAULT '0' COMMENT '是否为超级管理员',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`updatedAt` bigint(11) unsigned DEFAULT '0' COMMENT '修改时间',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='管理员';
CREATE TABLE `edgeDBNodes` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',
`role` varchar(255) DEFAULT NULL COMMENT '数据库角色',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`description` varchar(1024) DEFAULT NULL COMMENT '描述',
`host` varchar(255) DEFAULT NULL COMMENT '主机',
`port` int(11) unsigned DEFAULT '0' COMMENT '端口',
`database` varchar(255) DEFAULT NULL COMMENT '数据库名称',
`username` varchar(255) DEFAULT NULL COMMENT '用户名',
`password` varchar(255) DEFAULT NULL COMMENT '密码',
`charset` varchar(255) DEFAULT NULL COMMENT '通讯字符集',
`connTimeout` int(11) unsigned DEFAULT '0' COMMENT '连接超时时间(秒)',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`weight` int(11) unsigned DEFAULT '0' COMMENT '权重',
`order` int(11) unsigned DEFAULT '0' COMMENT '排序',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='数据库节点';
CREATE TABLE `edgeFileChunks` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`fileId` int(11) unsigned DEFAULT '0' COMMENT '文件ID',
`data` longblob COMMENT '分块内容',
PRIMARY KEY (`id`),
KEY `fileId` (`fileId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='文件片段';
CREATE TABLE `edgeFiles` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
`description` varchar(255) DEFAULT NULL COMMENT '文件描述',
`filename` varchar(255) DEFAULT NULL COMMENT '文件名',
`size` int(11) unsigned DEFAULT '0' COMMENT '文件尺寸',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`order` int(11) unsigned DEFAULT '0' COMMENT '排序',
`type` varchar(64) DEFAULT '' COMMENT '类型',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
PRIMARY KEY (`id`),
KEY `type` (`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='文件管理';
CREATE TABLE `edgeHTTPAccessLogPolicies` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`templateId` int(11) unsigned DEFAULT '0' COMMENT '模版ID',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',
`type` varchar(255) DEFAULT NULL COMMENT '存储类型',
`options` json DEFAULT NULL COMMENT '存储选项',
`conds` json DEFAULT NULL COMMENT '请求条件',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='访问日志策略';
CREATE TABLE `edgeHTTPAccessLogs` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`serverId` int(11) unsigned DEFAULT '0' COMMENT '服务ID',
`nodeId` int(11) unsigned DEFAULT '0' COMMENT '节点ID',
`status` int(3) unsigned DEFAULT '0' COMMENT '状态码',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`content` json DEFAULT NULL COMMENT '日志内容',
`requestId` varchar(128) DEFAULT NULL COMMENT '请求ID',
PRIMARY KEY (`id`),
KEY `serverId` (`serverId`),
KEY `nodeId` (`nodeId`),
KEY `serverId_status` (`serverId`,`status`),
KEY `requestId` (`requestId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `edgeHTTPAccessLogs_20201010` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`serverId` int(11) unsigned DEFAULT '0' COMMENT '服务ID',
`nodeId` int(11) unsigned DEFAULT '0' COMMENT '节点ID',
`status` int(3) unsigned DEFAULT '0' COMMENT '状态码',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`content` json DEFAULT NULL COMMENT '日志内容',
`day` varchar(8) DEFAULT NULL COMMENT '日期Ymd',
PRIMARY KEY (`id`),
KEY `serverId` (`serverId`),
KEY `nodeId` (`nodeId`),
KEY `serverId_status` (`serverId`,`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `edgeHTTPCachePolicies` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
`templateId` int(11) unsigned DEFAULT '0' COMMENT '模版ID',
`isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`capacity` json DEFAULT NULL COMMENT '容量数据',
`maxKeys` bigint(20) unsigned DEFAULT '0' COMMENT '最多Key值',
`maxSize` json DEFAULT NULL COMMENT '最大缓存内容尺寸',
`type` varchar(255) DEFAULT NULL COMMENT '存储类型',
`options` json DEFAULT NULL COMMENT '存储选项',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
`description` varchar(1024) DEFAULT NULL COMMENT '描述',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='HTTP缓存策略';
CREATE TABLE `edgeHTTPFirewallPolicies` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`templateId` int(11) unsigned DEFAULT '0' COMMENT '模版ID',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`description` varchar(1024) DEFAULT NULL COMMENT '描述',
`inbound` json DEFAULT NULL COMMENT '入站规则',
`outbound` json DEFAULT NULL COMMENT '出站规则',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='HTTP防火墙';
CREATE TABLE `edgeHTTPFirewallRuleGroups` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`description` varchar(1024) DEFAULT NULL COMMENT '描述',
`code` varchar(255) DEFAULT NULL COMMENT '代号',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
`sets` json DEFAULT NULL COMMENT '规则集列表',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='防火墙规则分组';
CREATE TABLE `edgeHTTPFirewallRuleSets` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',
`code` varchar(255) DEFAULT NULL COMMENT '代号',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`description` varchar(1024) DEFAULT NULL COMMENT '描述',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`rules` json DEFAULT NULL COMMENT '规则列表',
`connector` varchar(64) DEFAULT NULL COMMENT '规则之间的关系',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
`action` varchar(255) DEFAULT NULL COMMENT '执行的动作',
`actionOptions` json DEFAULT NULL COMMENT '动作的选项',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='防火墙规则集';
CREATE TABLE `edgeHTTPFirewallRules` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',
`description` varchar(1024) DEFAULT NULL COMMENT '说明',
`param` varchar(1024) DEFAULT NULL COMMENT '参数',
`operator` varchar(255) DEFAULT NULL COMMENT '操作符',
`value` varchar(1024) DEFAULT NULL COMMENT '对比值',
`isCaseInsensitive` tinyint(1) unsigned DEFAULT '1' COMMENT '是否大小写不敏感',
`checkpointOptions` json DEFAULT NULL COMMENT '检查点参数',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='防火墙规则';
CREATE TABLE `edgeHTTPGzips` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
`isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',
`level` int(11) unsigned DEFAULT '0' COMMENT '压缩级别',
`minLength` json DEFAULT NULL COMMENT '可压缩最小值',
`maxLength` json DEFAULT NULL COMMENT '可压缩最大值',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`conds` json DEFAULT NULL COMMENT '条件',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Gzip配置';
CREATE TABLE `edgeHTTPHeaderPolicies` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`isOn` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '是否启用',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`addHeaders` json DEFAULT NULL COMMENT '添加的Header',
`addTrailers` json DEFAULT NULL COMMENT '添加的Trailers',
`setHeaders` json DEFAULT NULL COMMENT '设置Header',
`replaceHeaders` json DEFAULT NULL COMMENT '替换Header内容',
`expires` json DEFAULT NULL COMMENT 'Expires单独设置',
`deleteHeaders` json DEFAULT NULL COMMENT '删除的Headers',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Header定义';
CREATE TABLE `edgeHTTPHeaders` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
`templateId` int(11) unsigned DEFAULT '0' COMMENT '模版ID',
`isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`value` varchar(1024) DEFAULT NULL COMMENT '',
`order` int(11) unsigned DEFAULT '0' COMMENT '排序',
`status` json DEFAULT NULL COMMENT '状态码设置',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='HTTP Header';
CREATE TABLE `edgeHTTPLocations` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`templateId` int(11) unsigned DEFAULT '0' COMMENT '模版ID',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
`parentId` int(11) unsigned DEFAULT '0' COMMENT '父级ID',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`pattern` varchar(1024) DEFAULT NULL COMMENT '匹配规则',
`isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`description` varchar(1024) DEFAULT NULL COMMENT '描述',
`webId` int(11) unsigned DEFAULT '0' COMMENT 'Web配置ID',
`reverseProxy` json DEFAULT NULL COMMENT '反向代理',
`urlPrefix` varchar(1024) DEFAULT NULL COMMENT 'URL前缀',
`isBreak` tinyint(1) unsigned DEFAULT '0' COMMENT '是否终止匹配',
`conds` json DEFAULT NULL COMMENT '匹配条件',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='路径规则配置';
CREATE TABLE `edgeHTTPPages` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
`isOn` tinyint(1) unsigned DEFAULT '0' COMMENT '是否启用',
`statusList` json DEFAULT NULL COMMENT '状态列表',
`url` varchar(1024) DEFAULT NULL COMMENT '页面URL',
`newStatus` int(3) DEFAULT NULL COMMENT '新状态码',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='特殊页面';
CREATE TABLE `edgeHTTPRewriteRules` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
`templateId` int(11) unsigned DEFAULT '0' COMMENT '模版ID',
`isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`pattern` varchar(1024) DEFAULT NULL COMMENT '匹配规则',
`replace` varchar(1024) DEFAULT NULL COMMENT '跳转后的地址',
`mode` varchar(255) DEFAULT NULL COMMENT '替换模式',
`redirectStatus` int(3) unsigned DEFAULT '0' COMMENT '跳转的状态码',
`proxyHost` varchar(255) DEFAULT NULL COMMENT '代理的主机名',
`isBreak` tinyint(1) unsigned DEFAULT '1' COMMENT '是否终止解析',
`withQuery` tinyint(1) unsigned DEFAULT '1' COMMENT '是否保留URI参数',
`conds` json DEFAULT NULL COMMENT '匹配条件',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='重写规则';
CREATE TABLE `edgeHTTPWebs` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',
`templateId` int(11) unsigned DEFAULT '0' COMMENT '模版ID',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`root` json DEFAULT NULL COMMENT '根目录',
`charset` json DEFAULT NULL COMMENT '字符集',
`shutdown` json DEFAULT NULL COMMENT '临时关闭页面配置',
`pages` json DEFAULT NULL COMMENT '特殊页面',
`redirectToHttps` json DEFAULT NULL COMMENT '跳转到HTTPS设置',
`indexes` json DEFAULT NULL COMMENT '首页文件列表',
`maxRequestBodySize` json DEFAULT NULL COMMENT '最大允许的请求内容尺寸',
`requestHeader` json DEFAULT NULL COMMENT '请求Header配置',
`responseHeader` json DEFAULT NULL COMMENT '响应Header配置',
`accessLog` json DEFAULT NULL COMMENT '访问日志配置',
`stat` json DEFAULT NULL COMMENT '统计配置',
`gzip` json DEFAULT NULL COMMENT 'Gzip配置',
`cache` json DEFAULT NULL COMMENT '缓存配置',
`firewall` json DEFAULT NULL COMMENT '防火墙设置',
`locations` json DEFAULT NULL COMMENT '路径规则配置',
`websocket` json DEFAULT NULL COMMENT 'Websocket设置',
`rewriteRules` json DEFAULT NULL COMMENT '重写规则配置',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='HTTP Web';
CREATE TABLE `edgeHTTPWebsockets` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
`isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',
`handshakeTimeout` json DEFAULT NULL COMMENT '握手超时时间',
`allowAllOrigins` tinyint(1) unsigned DEFAULT '1' COMMENT '是否支持所有源',
`allowedOrigins` json DEFAULT NULL COMMENT '支持的源域名列表',
`requestSameOrigin` tinyint(1) unsigned DEFAULT '1' COMMENT '是否请求一样的Origin',
`requestOrigin` varchar(255) DEFAULT NULL COMMENT '请求Origin',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Websocket设置';
CREATE TABLE `edgeLogs` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`level` varchar(32) DEFAULT NULL COMMENT '级别',
`description` varchar(255) DEFAULT NULL COMMENT '描述',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`action` varchar(255) DEFAULT NULL COMMENT '动作',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
`providerId` int(11) unsigned DEFAULT '0' COMMENT '供应商ID',
`ip` varchar(32) DEFAULT NULL COMMENT 'IP地址',
`type` varchar(255) DEFAULT 'admin' COMMENT '类型admin, user',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='操作日志';
CREATE TABLE `edgeNodeClusters` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`useAllAPINodes` tinyint(1) unsigned DEFAULT '1' COMMENT '是否使用所有API节点',
`apiNodes` json DEFAULT NULL COMMENT '使用的API节点',
`installDir` varchar(512) DEFAULT NULL COMMENT '安装目录',
`order` int(11) unsigned DEFAULT '0' COMMENT '排序',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`grantId` int(11) unsigned DEFAULT '0' COMMENT '默认认证方式',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='节点集群';
CREATE TABLE `edgeNodeGrants` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`method` varchar(64) DEFAULT NULL COMMENT '登录方式',
`username` varchar(255) DEFAULT NULL COMMENT '用户名',
`password` varchar(255) DEFAULT NULL COMMENT '密码',
`su` tinyint(1) unsigned DEFAULT '1' COMMENT '是否需要su',
`privateKey` varchar(4096) DEFAULT NULL COMMENT '密钥',
`description` varchar(255) DEFAULT NULL COMMENT '备注',
`nodeId` int(11) unsigned DEFAULT '0' COMMENT '专有节点',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='节点授权';
CREATE TABLE `edgeNodeGroups` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`order` int(11) unsigned DEFAULT '0' COMMENT '排序',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='节点分组';
CREATE TABLE `edgeNodeIPAddresses` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`nodeId` int(11) unsigned DEFAULT '0' COMMENT '节点ID',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`ip` varchar(128) DEFAULT NULL COMMENT 'IP地址',
`description` varchar(255) DEFAULT NULL COMMENT '描述',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
`order` int(11) unsigned DEFAULT '0' COMMENT '排序',
PRIMARY KEY (`id`),
KEY `nodeId` (`nodeId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='节点IP地址';
CREATE TABLE `edgeNodeLogins` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`nodeId` int(11) unsigned DEFAULT '0' COMMENT '节点ID',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`type` varchar(255) DEFAULT NULL COMMENT '类型ssh,agent',
`params` json DEFAULT NULL COMMENT '配置参数',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
PRIMARY KEY (`id`),
KEY `nodeId` (`nodeId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='节点登录信息';
CREATE TABLE `edgeNodeLogs` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`role` varchar(64) DEFAULT NULL COMMENT '节点角色',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`tag` varchar(255) DEFAULT NULL COMMENT '标签',
`description` varchar(1024) DEFAULT NULL COMMENT '描述',
`level` varchar(32) DEFAULT NULL COMMENT '级别',
`nodeId` int(11) unsigned DEFAULT '0' COMMENT '节点ID',
`day` varchar(8) DEFAULT NULL COMMENT '日期',
PRIMARY KEY (`id`),
KEY `level` (`level`),
KEY `day` (`day`),
KEY `role_nodeId` (`role`,`nodeId`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='节点日志';
CREATE TABLE `edgeNodeRegions` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`order` int(11) unsigned DEFAULT '0' COMMENT '排序',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='节点区域';
CREATE TABLE `edgeNodes` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
`isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',
`uniqueId` varchar(32) DEFAULT NULL COMMENT '节点ID',
`secret` varchar(32) DEFAULT NULL COMMENT '密钥',
`name` varchar(255) DEFAULT NULL COMMENT '节点名',
`code` varchar(255) DEFAULT NULL COMMENT '代号',
`clusterId` int(11) unsigned DEFAULT '0' COMMENT '集群ID',
`regionId` int(11) unsigned DEFAULT '0' COMMENT '区域ID',
`groupId` int(11) unsigned DEFAULT '0' COMMENT '分组ID',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`status` json DEFAULT NULL COMMENT '最新的状态',
`version` int(11) unsigned DEFAULT '0' COMMENT '当前版本号',
`latestVersion` int(11) unsigned DEFAULT '0' COMMENT '最后版本号',
`installDir` varchar(512) DEFAULT NULL COMMENT '安装目录',
`isInstalled` tinyint(1) unsigned DEFAULT '0' COMMENT '是否已安装',
`installStatus` json DEFAULT NULL COMMENT '安装状态',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
`connectedAPINodes` json DEFAULT NULL COMMENT '当前连接的API节点',
`maxCPU` int(4) unsigned DEFAULT '0' COMMENT '可以使用的最多CPU',
PRIMARY KEY (`id`),
KEY `uniqueId` (`uniqueId`),
KEY `clusterId` (`clusterId`),
KEY `groupId` (`groupId`),
KEY `regionId` (`regionId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='节点';
CREATE TABLE `edgeOrigins` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
`isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`version` int(11) unsigned DEFAULT '0' COMMENT '版本',
`addr` json DEFAULT NULL COMMENT '地址',
`description` varchar(512) DEFAULT NULL COMMENT '描述',
`code` varchar(255) DEFAULT NULL COMMENT '代号',
`weight` int(11) unsigned DEFAULT '0' COMMENT '权重',
`connTimeout` json DEFAULT NULL COMMENT '连接超时',
`readTimeout` json DEFAULT NULL COMMENT '读超时',
`idleTimeout` json DEFAULT NULL COMMENT '空闲连接超时',
`maxFails` int(11) unsigned DEFAULT '0' COMMENT '最多失败次数',
`maxConns` int(11) unsigned DEFAULT '0' COMMENT '最大并发连接数',
`maxIdleConns` int(11) unsigned DEFAULT '0' COMMENT '最多空闲连接数',
`httpRequestURI` varchar(1024) DEFAULT NULL COMMENT '转发后的请求URI',
`httpRequestHeader` json DEFAULT NULL COMMENT '请求Header配置',
`httpResponseHeader` json DEFAULT NULL COMMENT '响应Header配置',
`host` varchar(255) DEFAULT NULL COMMENT '自定义主机名',
`healthCheck` json DEFAULT NULL COMMENT '健康检查设置',
`cert` json DEFAULT NULL COMMENT '证书设置',
`ftp` json DEFAULT NULL COMMENT 'FTP相关设置',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='源站';
CREATE TABLE `edgeProviders` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`username` varchar(64) DEFAULT NULL COMMENT '用户名',
`password` varchar(32) DEFAULT NULL COMMENT '密码',
`fullname` varchar(64) DEFAULT NULL COMMENT '真实姓名',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`updatedAt` bigint(11) unsigned DEFAULT '0' COMMENT '修改时间',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='供应商';
CREATE TABLE `edgeReverseProxies` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
`templateId` int(11) unsigned DEFAULT '0' COMMENT '模版ID',
`isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',
`scheduling` json DEFAULT NULL COMMENT '调度算法',
`primaryOrigins` json DEFAULT NULL COMMENT '主要源站',
`backupOrigins` json DEFAULT NULL COMMENT '备用源站',
`stripPrefix` varchar(255) DEFAULT NULL COMMENT '去除URL前缀',
`requestHost` varchar(255) DEFAULT NULL COMMENT '请求Host',
`requestURI` varchar(1024) DEFAULT NULL COMMENT '请求URI',
`autoFlush` tinyint(1) unsigned DEFAULT '0' COMMENT '是否自动刷新缓冲区',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='反向代理配置';
CREATE TABLE `edgeSSLCertGroups` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
`name` varchar(255) DEFAULT NULL COMMENT '分组名',
`order` int(11) unsigned DEFAULT '0' COMMENT '分组排序',
`state` tinyint(1) unsigned DEFAULT '0' COMMENT '状态',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='证书分组';
CREATE TABLE `edgeSSLCerts` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`updatedAt` bigint(11) unsigned DEFAULT '0' COMMENT '修改时间',
`isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',
`name` varchar(255) DEFAULT NULL COMMENT '证书名',
`description` varchar(1024) DEFAULT NULL COMMENT '描述',
`certData` blob COMMENT '证书内容',
`keyData` blob COMMENT '密钥内容',
`serverName` varchar(255) DEFAULT NULL COMMENT '证书使用的主机名',
`isCA` tinyint(1) unsigned DEFAULT '0' COMMENT '是否为CA证书',
`groupIds` json DEFAULT NULL COMMENT '证书分组',
`timeBeginAt` bigint(11) unsigned DEFAULT '0' COMMENT '开始时间',
`timeEndAt` bigint(11) unsigned DEFAULT '0' COMMENT '结束时间',
`dnsNames` json DEFAULT NULL COMMENT 'DNS名称列表',
`commonNames` json DEFAULT NULL COMMENT '发行单位列表',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='SSL证书';
CREATE TABLE `edgeSSLPolicies` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
`isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',
`certs` json DEFAULT NULL COMMENT '证书列表',
`clientCACerts` json DEFAULT NULL COMMENT '客户端证书',
`clientAuthType` int(11) unsigned DEFAULT '0' COMMENT '客户端认证类型',
`minVersion` varchar(32) DEFAULT NULL COMMENT '支持的SSL最小版本',
`cipherSuitesIsOn` tinyint(1) unsigned DEFAULT '0' COMMENT '是否自定义加密算法套件',
`cipherSuites` json DEFAULT NULL COMMENT '加密算法套件',
`hsts` json DEFAULT NULL COMMENT 'HSTS设置',
`http2Enabled` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用HTTP/2',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='SSL配置策略';
CREATE TABLE `edgeServerGroups` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`order` int(11) unsigned DEFAULT '0' COMMENT '排序',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='服务分组';
CREATE TABLE `edgeServers` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
`adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',
`type` varchar(64) DEFAULT NULL COMMENT '服务类型',
`name` varchar(255) DEFAULT NULL COMMENT '名称',
`description` varchar(512) DEFAULT NULL COMMENT '描述',
`serverNames` json DEFAULT NULL COMMENT '域名列表',
`http` json DEFAULT NULL COMMENT 'HTTP配置',
`https` json DEFAULT NULL COMMENT 'HTTPS配置',
`tcp` json DEFAULT NULL COMMENT 'TCP配置',
`tls` json DEFAULT NULL COMMENT 'TLS配置',
`unix` json DEFAULT NULL COMMENT 'Unix配置',
`udp` json DEFAULT NULL COMMENT 'UDP配置',
`webId` int(11) unsigned DEFAULT '0' COMMENT 'WEB配置',
`reverseProxy` json DEFAULT NULL COMMENT '反向代理配置',
`groupIds` json DEFAULT NULL COMMENT '分组ID列表',
`config` json DEFAULT NULL COMMENT '服务配置,自动生成',
`configMd5` varchar(32) DEFAULT NULL COMMENT 'Md5',
`clusterId` int(11) unsigned DEFAULT '0' COMMENT '集群ID',
`includeNodes` json DEFAULT NULL COMMENT '部署条件',
`excludeNodes` json DEFAULT NULL COMMENT '节点排除条件',
`version` int(11) unsigned DEFAULT '0' COMMENT '版本号',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
PRIMARY KEY (`id`),
KEY `userId` (`userId`),
KEY `adminId` (`adminId`),
KEY `isUpdating_state` (`state`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='服务';
CREATE TABLE `edgeSysEvents` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`type` varchar(255) DEFAULT NULL COMMENT '类型',
`params` json DEFAULT NULL COMMENT '参数',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统事件';
CREATE TABLE `edgeSysLockers` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`key` varchar(255) DEFAULT NULL COMMENT '键值',
`version` bigint(20) unsigned DEFAULT '0' COMMENT '版本号',
`timeoutAt` bigint(11) unsigned DEFAULT '0' COMMENT '超时时间',
PRIMARY KEY (`id`),
UNIQUE KEY `key` (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='并发锁';
CREATE TABLE `edgeSysSettings` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
`code` varchar(255) DEFAULT NULL COMMENT '代号',
`value` json DEFAULT NULL COMMENT '配置值',
PRIMARY KEY (`id`),
UNIQUE KEY `code` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统配置';
CREATE TABLE `edgeTCPFirewallPolicies` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`adminId` int(11) DEFAULT NULL COMMENT '管理员ID',
`userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',
`templateId` int(11) unsigned DEFAULT '0' COMMENT '模版ID',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='TCP防火墙';
CREATE TABLE `edgeUsers` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`username` varchar(64) DEFAULT NULL COMMENT '用户名',
`password` varchar(32) DEFAULT NULL COMMENT '密码',
`fullname` varchar(64) DEFAULT NULL COMMENT '真实姓名',
`createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',
`updatedAt` bigint(11) unsigned DEFAULT '0' COMMENT '修改时间',
`state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户';
CREATE TABLE `edgeVersions` (
`id` bigint(16) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`version` varchar(64) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='数据库结构版本';

77
cmd/sql-dump/main.go Normal file
View File

@@ -0,0 +1,77 @@
package main
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAPI/internal/setup"
_ "github.com/iwind/TeaGo/bootstrap"
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/logs"
"go/format"
"io/ioutil"
"os"
"path/filepath"
"strconv"
)
func main() {
db, err := dbs.Default()
if err != nil {
logs.Println("[ERROR]" + err.Error())
return
}
results, err := setup.NewSQLDump().Dump(db)
if err != nil {
logs.Println("[ERROR]" + err.Error())
return
}
resultsJSON, err := json.Marshal(results)
if err != nil {
logs.Println("[ERROR]" + err.Error())
return
}
dir, _ := os.Getwd()
var sqlFile string
for i := 0; i < 5; i++ {
lookupFile := dir + "/internal/setup/sql.go"
_, err = os.Stat(lookupFile)
if err != nil {
dir = filepath.Dir(dir)
continue
}
sqlFile = lookupFile
}
if len(sqlFile) == 0 {
logs.Println("[ERROR]can not find sql.go")
return
}
content := []byte(`package setup
import (
"encoding/json"
"github.com/iwind/TeaGo/logs"
)
// 最新的SQL语句
// 由sql-dump/main.go自动生成
func init() {
err := json.Unmarshal([]byte(` + strconv.Quote(string(resultsJSON)) + `), LatestSQLResult)
if err != nil {
logs.Println("[ERROR]load sql failed: " + err.Error())
}
}
`)
dst, err := format.Source(content)
if err != nil {
logs.Println("[ERROR]format code failed: " + err.Error())
return
}
err = ioutil.WriteFile(sqlFile, dst, 0666)
if err != nil {
logs.Println("[ERROR]write file failed: " + err.Error())
return
}
logs.Println("ok")
}

View File

@@ -1,103 +0,0 @@
package main
import (
"bytes"
"flag"
"fmt"
"github.com/iwind/TeaGo/Tea"
_ "github.com/iwind/TeaGo/bootstrap"
"github.com/iwind/TeaGo/logs"
"go/format"
"io/ioutil"
"os"
"path/filepath"
"strings"
)
func main() {
var dir string
flag.StringVar(&dir, "dir", "", "SQL dir")
flag.Parse()
if len(dir) == 0 {
fmt.Println("[ERROR]'dir' should not be empty")
return
}
sourceDir := filepath.Dir(Tea.Root)
// full
fullSQLFile := dir + "/full.sql"
_, err := os.Stat(fullSQLFile)
if err != nil {
if os.IsNotExist(err) {
fmt.Println("[ERROR]'full.sql' not found")
return
}
fmt.Println("[ERROR]checking 'full.sql' failed: " + err.Error())
return
}
matches, err := filepath.Glob(dir + "/*.sql")
if err != nil {
fmt.Println("[ERROR]" + err.Error())
return
}
versionsCode := "// generated\npackage sqls\n\nvar SQLVersions = []map[string]string{"
for _, match := range matches {
baseName := filepath.Base(match)
logs.Println("reading " + baseName + " ...")
data, err := ioutil.ReadFile(match)
if err != nil {
fmt.Println("[ERROR]" + err.Error())
return
}
version := baseName[:strings.LastIndex(baseName, ".")]
versionsCode += "\n" + `{ "version": "` + version + `", "sql": SQL_` + version + ` },`
code := "// generated\npackage sqls \n\n"
lines := bytes.Split(data, []byte{'\n'})
for index, line := range lines {
if index == 0 {
code += "var SQL_" + version + " = "
}
code += `"` + string(line) + `\n"`
if index != len(lines)-1 {
code += "+"
}
code += "\n"
}
code += "\n"
codeBytes, err := format.Source([]byte(code))
if err != nil {
fmt.Println("[ERROR]" + err.Error())
return
}
fmt.Println("writing sql_" + version + ".go ...")
err = ioutil.WriteFile(sourceDir+"/internal/setup/sqls/sql_"+version+".go", codeBytes, 0666)
if err != nil {
fmt.Println("[ERROR]" + err.Error())
return
}
fmt.Println("ok")
}
versionsCode += "\n}"
versionsCodeBytes, err := format.Source([]byte(versionsCode))
if err != nil {
fmt.Println("[ERROR]" + err.Error())
return
}
fmt.Println("writing sqls.go ...")
err = ioutil.WriteFile(sourceDir+"/internal/setup/sqls/sqls.go", versionsCodeBytes, 0666)
if err != nil {
fmt.Println("[ERROR]" + err.Error())
return
}
fmt.Println("ok")
}

View File

@@ -1,7 +1,7 @@
package teaconst
const (
Version = "0.0.1"
Version = "0.0.2"
ProductName = "Edge API"
ProcessName = "edge-api"

View File

@@ -862,7 +862,7 @@ func (this *ServerDAO) createEvent() error {
return SharedSysEventDAO.CreateEvent(NewServerChangeEvent())
}
// 查询当前服务的ClusterId
// 查询当前服务的集群ID
func (this *ServerDAO) FindServerClusterId(serverId int64) (int64, error) {
return this.Query().
Pk(serverId).
@@ -870,6 +870,14 @@ func (this *ServerDAO) FindServerClusterId(serverId int64) (int64, error) {
FindInt64Col(0)
}
// 查询服务的DNS名称
func (this *ServerDAO) FindServerDNSName(serverId int64) (string, error) {
return this.Query().
Pk(serverId).
Result("dnsName").
FindStringCol("")
}
// 生成DNS Name
func (this *ServerDAO) genDNSName() (string, error) {
for {

View File

@@ -903,6 +903,52 @@ func (this *ServerService) FindAllEnabledServersDNSWithClusterId(ctx context.Con
return &pb.FindAllEnabledServersDNSWithClusterIdResponse{Servers: result}, nil
}
// 查找单个服务的DNS信息
func (this *ServerService) FindEnabledServerDNS(ctx context.Context, req *pb.FindEnabledServerDNSRequest) (*pb.FindEnabledServerDNSResponse, error) {
// 校验请求
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
if err != nil {
return nil, err
}
dnsName, err := models.SharedServerDAO.FindServerDNSName(req.ServerId)
if err != nil {
return nil, err
}
clusterId, err := models.SharedServerDAO.FindServerClusterId(req.ServerId)
if err != nil {
return nil, err
}
var pbDomain *pb.DNSDomain = nil
if clusterId > 0 {
clusterDNS, err := models.SharedNodeClusterDAO.FindClusterDNSInfo(clusterId)
if err != nil {
return nil, err
}
if clusterDNS != nil {
domainId := int64(clusterDNS.DnsDomainId)
if domainId > 0 {
domain, err := models.SharedDNSDomainDAO.FindEnabledDNSDomain(domainId)
if err != nil {
return nil, err
}
if domain != nil {
pbDomain = &pb.DNSDomain{
Id: domainId,
Name: domain.Name,
}
}
}
}
}
return &pb.FindEnabledServerDNSResponse{
DnsName: dnsName,
Domain: pbDomain,
}, nil
}
// 自动同步DNS状态
func (this *ServerService) notifyServerDNSChanged(serverId int64) error {
clusterId, err := models.SharedServerDAO.FindServerClusterId(serverId)

16
internal/setup/sql.go Normal file

File diff suppressed because one or more lines are too long

256
internal/setup/sql_dump.go Normal file
View File

@@ -0,0 +1,256 @@
package setup
import (
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/types"
"regexp"
"strings"
)
var recordsTables = []*SQLRecordsTable{
{
TableName: "edgeRegionCities",
UniqueFields: []string{"name", "provinceId"},
},
{
TableName: "edgeRegionCountries",
UniqueFields: []string{"name"},
},
{
TableName: "edgeRegionProvinces",
UniqueFields: []string{"name", "countryId"},
},
}
type SQLDump struct {
}
func NewSQLDump() *SQLDump {
return &SQLDump{}
}
// 导出数据
func (this *SQLDump) Dump(db *dbs.DB) (result *SQLDumpResult, err error) {
result = &SQLDumpResult{}
tableNames, err := db.TableNames()
if err != nil {
return result, err
}
for _, tableName := range tableNames {
// 忽略一些分表
if strings.HasPrefix(tableName, "edgeHTTPAccessLogs_") {
continue
}
table, err := db.FindFullTable(tableName)
if err != nil {
return nil, err
}
sqlTable := &SQLTable{
Name: table.Name,
Engine: table.Engine,
Charset: table.Collation,
Definition: regexp.MustCompile(" AUTO_INCREMENT=\\d+").ReplaceAllString(table.Code, ""),
}
// 字段
fields := []*SQLField{}
for _, field := range table.Fields {
fields = append(fields, &SQLField{
Name: field.Name,
Definition: field.Definition(),
})
}
sqlTable.Fields = fields
// 索引
indexes := []*SQLIndex{}
for _, index := range table.Indexes {
indexes = append(indexes, &SQLIndex{
Name: index.Name,
Definition: index.Definition(),
})
}
sqlTable.Indexes = indexes
// Records
records := []*SQLRecord{}
recordsTable := this.findRecordsTable(tableName)
if recordsTable != nil {
ones, _, err := db.FindOnes("SELECT * FROM " + tableName + " ORDER BY id ASC")
if err != nil {
return result, err
}
for _, one := range ones {
record := &SQLRecord{
Id: one.GetInt64("id"),
Values: map[string]string{},
UniqueFields: recordsTable.UniqueFields,
}
for k, v := range one {
record.Values[k] = types.String(v)
}
records = append(records, record)
}
}
sqlTable.Records = records
result.Tables = append(result.Tables, sqlTable)
}
return
}
// 应用数据
func (this *SQLDump) Apply(db *dbs.DB, newResult *SQLDumpResult) (ops []string, err error) {
currentResult, err := this.Dump(db)
if err != nil {
return nil, err
}
// 新增表格
for _, newTable := range newResult.Tables {
oldTable := currentResult.FindTable(newTable.Name)
if oldTable == nil {
ops = append(ops, "+ table "+newTable.Name)
_, err = db.Exec(newTable.Definition)
if err != nil {
return nil, err
}
} else if oldTable.Definition != newTable.Definition {
// 对比字段
// +
for _, newField := range newTable.Fields {
oldField := oldTable.FindField(newField.Name)
if oldField == nil {
ops = append(ops, "+ "+newTable.Name+" "+newField.Name)
_, err = db.Exec("ALTER TABLE " + newTable.Name + " ADD " + newField.Name + " " + newField.Definition)
if err != nil {
return nil, err
}
} else if oldField.Definition != newField.Definition {
ops = append(ops, "* "+newTable.Name+" "+newField.Name)
_, err = db.Exec("ALTER TABLE " + newTable.Name + " MODIFY " + newField.Name + " " + newField.Definition)
if err != nil {
return nil, err
}
}
}
// 对比索引
// +
for _, newIndex := range newTable.Indexes {
oldIndex := oldTable.FindIndex(newIndex.Name)
if oldIndex == nil {
ops = append(ops, "+ index "+newTable.Name+" "+newIndex.Name)
_, err = db.Exec("ALTER TABLE " + newTable.Name + " ADD " + newIndex.Definition)
if err != nil {
return nil, err
}
} else if oldIndex.Definition != newIndex.Definition {
ops = append(ops, "* index "+newTable.Name+" "+newIndex.Name)
_, err = db.Exec("ALTER TABLE " + newTable.Name + " DROP KEY " + newIndex.Name)
if err != nil {
return nil, err
}
_, err = db.Exec("ALTER TABLE " + newTable.Name + " ADD " + newIndex.Definition)
if err != nil {
return nil, err
}
}
}
// -
for _, oldIndex := range oldTable.Indexes {
newIndex := newTable.FindIndex(oldIndex.Name)
if newIndex == nil {
ops = append(ops, "- index "+oldTable.Name+" "+oldIndex.Name)
_, err = db.Exec("ALTER TABLE " + oldTable.Name + " DROP KEY " + oldIndex.Name)
if err != nil {
return nil, err
}
}
}
// 对比字段
// -
for _, oldField := range oldTable.Fields {
newField := newTable.FindField(oldField.Name)
if newField == nil {
ops = append(ops, "- field "+oldTable.Name+" "+oldField.Name)
_, err = db.Exec("ALTER TABLE " + oldTable.Name + " DROP COLUMN " + oldField.Name)
if err != nil {
return nil, err
}
}
}
}
// 对比记录
// +
for _, record := range newTable.Records {
queryArgs := []string{}
queryValues := []interface{}{}
valueStrings := []string{}
for _, field := range record.UniqueFields {
queryArgs = append(queryArgs, field+"=?")
queryValues = append(queryValues, record.Values[field])
valueStrings = append(valueStrings, record.Values[field])
}
one, err := db.FindOne("SELECT * FROM "+newTable.Name+" WHERE "+strings.Join(queryArgs, " AND "), queryValues...)
if err != nil {
return nil, err
}
if one == nil {
ops = append(ops, "+ record "+newTable.Name+" "+strings.Join(valueStrings, ", "))
params := []string{}
args := []string{}
values := []interface{}{}
for k, v := range record.Values {
if k == "id" {
continue
}
params = append(params, "`"+k+"`")
args = append(args, "?")
values = append(values, v)
}
_, err = db.Exec("INSERT INTO "+newTable.Name+" ("+strings.Join(params, ", ")+") VALUES ("+strings.Join(args, ", ")+")", values...)
if err != nil {
return nil, err
}
} else if !record.ValuesEquals(one) {
ops = append(ops, "* record "+newTable.Name+" "+strings.Join(valueStrings, ", "))
args := []string{}
values := []interface{}{}
for k, v := range record.Values {
if k == "id" {
continue
}
args = append(args, k+"=?")
values = append(values, v)
}
values = append(values, one.GetInt("id"))
_, err = db.Exec("UPDATE " + newTable.Name + " SET " + strings.Join(args, ", ") + " WHERE id=?", values...)
if err != nil {
return nil, err
}
}
}
}
// 减少表格
// 由于我们不删除任何表格,所以这里什么都不做
return
}
// 查找有记录的表
func (this *SQLDump) findRecordsTable(tableName string) *SQLRecordsTable {
for _, table := range recordsTables {
if table.TableName == tableName {
return table
}
}
return nil
}

View File

@@ -0,0 +1,14 @@
package setup
type SQLDumpResult struct {
Tables []*SQLTable `json:"tables"`
}
func (this *SQLDumpResult) FindTable(tableName string) *SQLTable {
for _, table := range this.Tables {
if table.Name == tableName {
return table
}
}
return nil
}

View File

@@ -0,0 +1,77 @@
package setup
import (
"encoding/json"
"github.com/iwind/TeaGo/dbs"
"testing"
)
func TestSQLDump_Dump(t *testing.T) {
db, err := dbs.NewInstanceFromConfig(&dbs.DBConfig{
Driver: "mysql",
Dsn: "root:123456@tcp(127.0.0.1:3306)/db_edge?charset=utf8mb4&timeout=30s",
Prefix: "edge",
})
dump := NewSQLDump()
result, err := dump.Dump(db)
if err != nil {
t.Fatal(err)
}
// Table
for _, table := range result.Tables {
_ = table
//t.Log(table.Name, table.Engine, table.Charset)
/**for _, field := range table.Fields {
t.Log("===", field.Name, ":", field.Definition)
}**/
/**for _, index := range table.Indexes {
t.Log("===", index.Name, ":", index.Definition)
}**/
/**for _, record := range table.Records {
t.Log(record.Id, record.Values)
}**/
}
data, err := json.Marshal(result)
if err != nil {
t.Fatal(err)
}
t.Log(len(data), "bytes")
}
func TestSQLDump_Apply(t *testing.T) {
db, err := dbs.NewInstanceFromConfig(&dbs.DBConfig{
Driver: "mysql",
Dsn: "root:123456@tcp(127.0.0.1:3306)/db_edge?charset=utf8mb4&timeout=30s",
Prefix: "edge",
})
dump := NewSQLDump()
result, err := dump.Dump(db)
if err != nil {
t.Fatal(err)
}
db2, err := dbs.NewInstanceFromConfig(&dbs.DBConfig{
Driver: "mysql",
Dsn: "root:123456@tcp(127.0.0.1:3306)/db_edge_new?charset=utf8mb4&timeout=30s",
Prefix: "edge",
})
if err != nil {
t.Fatal(err)
}
ops, err := dump.Apply(db2, result)
if err != nil {
t.Fatal(err)
}
t.Log("ok")
if len(ops) > 0 {
for _, op := range ops {
t.Log("", op)
}
}
}

View File

@@ -3,21 +3,20 @@ package setup
import (
teaconst "github.com/TeaOSLab/EdgeAPI/internal/const"
"github.com/TeaOSLab/EdgeAPI/internal/errors"
"github.com/TeaOSLab/EdgeAPI/internal/setup/sqls"
_ "github.com/go-sql-driver/mysql"
"github.com/go-yaml/yaml"
"github.com/iwind/TeaGo/Tea"
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/lists"
"github.com/iwind/TeaGo/rands"
"github.com/iwind/TeaGo/types"
stringutil "github.com/iwind/TeaGo/utils/string"
"io/ioutil"
"sort"
"strings"
"time"
)
var LatestSQLResult = &SQLDumpResult{}
// 安装或升级SQL执行器
type SQLExecutor struct {
dbConfig *dbs.DBConfig
@@ -49,92 +48,12 @@ func (this *SQLExecutor) Run() error {
return err
}
tableNames, err := db.TableNames()
sqlDump := NewSQLDump()
_, err = sqlDump.Apply(db, LatestSQLResult)
if err != nil {
return err
}
// 检查已有数据
if lists.ContainsString(tableNames, "edgeVersions") {
stmt, err := db.Prepare("SELECT version FROM " + db.TablePrefix() + "Versions")
if err != nil {
return err
}
defer func() {
_ = stmt.Close()
}()
rows, err := stmt.Query()
if err != nil {
return err
}
defer func() {
_ = rows.Close()
}()
// 对比版本
oldVersion := ""
if rows.Next() {
err = rows.Scan(&oldVersion)
if err != nil {
return errors.New("query version failed: " + err.Error())
}
}
if oldVersion == teaconst.Version {
err = this.checkData(db)
if err != nil {
return err
}
return nil
}
oldVersion = strings.Replace(oldVersion, "_", ".", -1)
upgradeVersions := []string{}
sqlMap := map[string]string{} // version => sql
for _, m := range sqls.SQLVersions {
version, _ := m["version"]
if version == "full" {
continue
}
version = strings.Replace(version, "_", ".", -1)
if len(oldVersion) == 0 || stringutil.VersionCompare(version, oldVersion) > 0 {
upgradeVersions = append(upgradeVersions, version)
sql, _ := m["sql"]
sqlMap[version] = sql
}
}
// 如果没有可以升级的版本,直接返回
if len(upgradeVersions) == 0 {
err = this.checkData(db)
if err != nil {
return err
}
return nil
}
sort.Slice(upgradeVersions, func(i, j int) bool {
return stringutil.VersionCompare(upgradeVersions[i], upgradeVersions[j]) < 0
})
// 执行升级的SQL
for _, version := range upgradeVersions {
sql := sqlMap[version]
_, err = db.Exec(sql)
if err != nil {
if !this.canIgnoreError(err) {
return errors.New("exec upgrade sql for version '" + version + "' failed: " + err.Error())
}
}
err = this.updateVersion(db, version)
if err != nil {
return err
}
}
// 检查数据
err = this.checkData(db)
if err != nil {
@@ -144,39 +63,6 @@ func (this *SQLExecutor) Run() error {
return nil
}
// 全新安装
fullSQL, found := this.findFullSQL()
if !found {
return errors.New("not found full setup sql")
}
// 执行SQL
_, err = db.Exec(fullSQL)
if err != nil {
return errors.New("create tables failed: " + err.Error())
}
// 检查数据
err = this.checkData(db)
if err != nil {
return err
}
return nil
}
// 查找完整的SQL
func (this *SQLExecutor) findFullSQL() (sql string, found bool) {
for _, m := range sqls.SQLVersions {
code, _ := m["version"]
if code == "full" {
sql, found = m["sql"]
return
}
}
return
}
// 检查数据
func (this *SQLExecutor) checkData(db *dbs.DB) error {
// 检查管理员

View File

@@ -0,0 +1,6 @@
package setup
type SQLField struct {
Name string `json:"name"`
Definition string `json:"definition"`
}

View File

@@ -0,0 +1,6 @@
package setup
type SQLIndex struct {
Name string `json:"name"`
Definition string `json:"definition"`
}

View File

@@ -0,0 +1,25 @@
package setup
import (
"github.com/iwind/TeaGo/maps"
"github.com/iwind/TeaGo/types"
)
type SQLRecord struct {
Id int64 `json:"id"`
Values map[string]string `json:"values"`
UniqueFields []string `json:"uniqueFields"`
}
func (this *SQLRecord) ValuesEquals(values maps.Map) bool {
for k, v := range values {
if k == "id" {
continue
}
vString := types.String(v)
if this.Values[k] != vString {
return false
}
}
return true
}

View File

@@ -0,0 +1,6 @@
package setup
type SQLRecordsTable struct {
TableName string
UniqueFields []string
}

View File

@@ -0,0 +1,38 @@
package setup
type SQLTable struct {
Name string `json:"name"`
Engine string `json:"engine"`
Charset string `json:"charset"`
Definition string `json:"definition"`
Fields []*SQLField `json:"fields"`
Indexes []*SQLIndex `json:"indexes"`
Records []*SQLRecord `json:"records"`
}
func (this *SQLTable) FindField(fieldName string) *SQLField {
for _, field := range this.Fields {
if field.Name == fieldName {
return field
}
}
return nil
}
func (this *SQLTable) FindIndex(indexName string) *SQLIndex {
for _, index := range this.Indexes {
if index.Name == indexName {
return index
}
}
return nil
}
func (this *SQLTable) FindRecord(id int64) *SQLRecord {
for _, record := range this.Records {
if record.Id == id {
return record
}
}
return nil
}

View File

@@ -1,642 +0,0 @@
// generated
package sqls
var SQL_full = "CREATE TABLE `edgeAPINodes` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n" +
" `clusterId` int(11) unsigned DEFAULT '0' COMMENT '专用集群ID',\n" +
" `uniqueId` varchar(32) DEFAULT NULL COMMENT '唯一ID',\n" +
" `secret` varchar(32) DEFAULT NULL COMMENT '密钥',\n" +
" `name` varchar(255) DEFAULT NULL COMMENT '名称',\n" +
" `description` varchar(1024) DEFAULT NULL COMMENT '描述',\n" +
" `http` json DEFAULT NULL COMMENT '监听的HTTP配置',\n" +
" `https` json DEFAULT NULL COMMENT '监听的HTTPS配置',\n" +
" `accessAddrs` json DEFAULT NULL COMMENT '外部访问地址',\n" +
" `order` int(11) unsigned DEFAULT '0' COMMENT '排序',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" `weight` int(11) unsigned DEFAULT '0' COMMENT '权重',\n" +
" `status` json DEFAULT NULL COMMENT '运行状态',\n" +
" PRIMARY KEY (`id`),\n" +
" UNIQUE KEY `uniqueId` (`uniqueId`) USING BTREE\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='API节点';\n" +
"CREATE TABLE `edgeAPITokens` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `nodeId` varchar(32) DEFAULT NULL COMMENT '节点ID',\n" +
" `secret` varchar(255) DEFAULT NULL COMMENT '节点密钥',\n" +
" `role` varchar(64) DEFAULT NULL COMMENT '节点角色',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" PRIMARY KEY (`id`),\n" +
" KEY `nodeId` (`nodeId`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='API令牌管理';\n" +
"CREATE TABLE `edgeAdmins` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `username` varchar(64) DEFAULT NULL COMMENT '用户名',\n" +
" `password` varchar(32) DEFAULT NULL COMMENT '密码',\n" +
" `fullname` varchar(64) DEFAULT NULL COMMENT '全名',\n" +
" `isSuper` tinyint(1) unsigned DEFAULT '0' COMMENT '是否为超级管理员',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `updatedAt` bigint(11) unsigned DEFAULT '0' COMMENT '修改时间',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='管理员';\n" +
"CREATE TABLE `edgeDBNodes` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n" +
" `role` varchar(255) DEFAULT NULL COMMENT '数据库角色',\n" +
" `name` varchar(255) DEFAULT NULL COMMENT '名称',\n" +
" `description` varchar(1024) DEFAULT NULL COMMENT '描述',\n" +
" `host` varchar(255) DEFAULT NULL COMMENT '主机',\n" +
" `port` int(11) unsigned DEFAULT '0' COMMENT '端口',\n" +
" `database` varchar(255) DEFAULT NULL COMMENT '数据库名称',\n" +
" `username` varchar(255) DEFAULT NULL COMMENT '用户名',\n" +
" `password` varchar(255) DEFAULT NULL COMMENT '密码',\n" +
" `charset` varchar(255) DEFAULT NULL COMMENT '通讯字符集',\n" +
" `connTimeout` int(11) unsigned DEFAULT '0' COMMENT '连接超时时间(秒)',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `weight` int(11) unsigned DEFAULT '0' COMMENT '权重',\n" +
" `order` int(11) unsigned DEFAULT '0' COMMENT '排序',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='数据库节点';\n" +
"CREATE TABLE `edgeFileChunks` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `fileId` int(11) unsigned DEFAULT '0' COMMENT '文件ID',\n" +
" `data` longblob COMMENT '分块内容',\n" +
" PRIMARY KEY (`id`),\n" +
" KEY `fileId` (`fileId`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='文件片段';\n" +
"CREATE TABLE `edgeFiles` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" `description` varchar(255) DEFAULT NULL COMMENT '文件描述',\n" +
" `filename` varchar(255) DEFAULT NULL COMMENT '文件名',\n" +
" `size` int(11) unsigned DEFAULT '0' COMMENT '文件尺寸',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `order` int(11) unsigned DEFAULT '0' COMMENT '排序',\n" +
" `type` varchar(64) DEFAULT '' COMMENT '类型',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" PRIMARY KEY (`id`),\n" +
" KEY `type` (`type`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='文件管理';\n" +
"CREATE TABLE `edgeHTTPAccessLogPolicies` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `templateId` int(11) unsigned DEFAULT '0' COMMENT '模版ID',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `name` varchar(255) DEFAULT NULL COMMENT '名称',\n" +
" `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n" +
" `type` varchar(255) DEFAULT NULL COMMENT '存储类型',\n" +
" `options` json DEFAULT NULL COMMENT '存储选项',\n" +
" `conds` json DEFAULT NULL COMMENT '请求条件',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='访问日志策略';\n" +
"CREATE TABLE `edgeHTTPAccessLogs` (\n" +
" `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `serverId` int(11) unsigned DEFAULT '0' COMMENT '服务ID',\n" +
" `nodeId` int(11) unsigned DEFAULT '0' COMMENT '节点ID',\n" +
" `status` int(3) unsigned DEFAULT '0' COMMENT '状态码',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `content` json DEFAULT NULL COMMENT '日志内容',\n" +
" `requestId` varchar(128) DEFAULT NULL COMMENT '请求ID',\n" +
" PRIMARY KEY (`id`),\n" +
" KEY `serverId` (`serverId`),\n" +
" KEY `nodeId` (`nodeId`),\n" +
" KEY `serverId_status` (`serverId`,`status`),\n" +
" KEY `requestId` (`requestId`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;\n" +
"CREATE TABLE `edgeHTTPAccessLogs_20201010` (\n" +
" `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `serverId` int(11) unsigned DEFAULT '0' COMMENT '服务ID',\n" +
" `nodeId` int(11) unsigned DEFAULT '0' COMMENT '节点ID',\n" +
" `status` int(3) unsigned DEFAULT '0' COMMENT '状态码',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `content` json DEFAULT NULL COMMENT '日志内容',\n" +
" `day` varchar(8) DEFAULT NULL COMMENT '日期Ymd',\n" +
" PRIMARY KEY (`id`),\n" +
" KEY `serverId` (`serverId`),\n" +
" KEY `nodeId` (`nodeId`),\n" +
" KEY `serverId_status` (`serverId`,`status`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;\n" +
"CREATE TABLE `edgeHTTPCachePolicies` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" `templateId` int(11) unsigned DEFAULT '0' COMMENT '模版ID',\n" +
" `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n" +
" `name` varchar(255) DEFAULT NULL COMMENT '名称',\n" +
" `capacity` json DEFAULT NULL COMMENT '容量数据',\n" +
" `maxKeys` bigint(20) unsigned DEFAULT '0' COMMENT '最多Key值',\n" +
" `maxSize` json DEFAULT NULL COMMENT '最大缓存内容尺寸',\n" +
" `type` varchar(255) DEFAULT NULL COMMENT '存储类型',\n" +
" `options` json DEFAULT NULL COMMENT '存储选项',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" `description` varchar(1024) DEFAULT NULL COMMENT '描述',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='HTTP缓存策略';\n" +
"CREATE TABLE `edgeHTTPFirewallPolicies` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `templateId` int(11) unsigned DEFAULT '0' COMMENT '模版ID',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n" +
" `name` varchar(255) DEFAULT NULL COMMENT '名称',\n" +
" `description` varchar(1024) DEFAULT NULL COMMENT '描述',\n" +
" `inbound` json DEFAULT NULL COMMENT '入站规则',\n" +
" `outbound` json DEFAULT NULL COMMENT '出站规则',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='HTTP防火墙';\n" +
"CREATE TABLE `edgeHTTPFirewallRuleGroups` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n" +
" `name` varchar(255) DEFAULT NULL COMMENT '名称',\n" +
" `description` varchar(1024) DEFAULT NULL COMMENT '描述',\n" +
" `code` varchar(255) DEFAULT NULL COMMENT '代号',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" `sets` json DEFAULT NULL COMMENT '规则集列表',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='防火墙规则分组';\n" +
"CREATE TABLE `edgeHTTPFirewallRuleSets` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n" +
" `code` varchar(255) DEFAULT NULL COMMENT '代号',\n" +
" `name` varchar(255) DEFAULT NULL COMMENT '名称',\n" +
" `description` varchar(1024) DEFAULT NULL COMMENT '描述',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `rules` json DEFAULT NULL COMMENT '规则列表',\n" +
" `connector` varchar(64) DEFAULT NULL COMMENT '规则之间的关系',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" `action` varchar(255) DEFAULT NULL COMMENT '执行的动作',\n" +
" `actionOptions` json DEFAULT NULL COMMENT '动作的选项',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='防火墙规则集';\n" +
"CREATE TABLE `edgeHTTPFirewallRules` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n" +
" `description` varchar(1024) DEFAULT NULL COMMENT '说明',\n" +
" `param` varchar(1024) DEFAULT NULL COMMENT '参数',\n" +
" `operator` varchar(255) DEFAULT NULL COMMENT '操作符',\n" +
" `value` varchar(1024) DEFAULT NULL COMMENT '对比值',\n" +
" `isCaseInsensitive` tinyint(1) unsigned DEFAULT '1' COMMENT '是否大小写不敏感',\n" +
" `checkpointOptions` json DEFAULT NULL COMMENT '检查点参数',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='防火墙规则';\n" +
"CREATE TABLE `edgeHTTPGzips` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n" +
" `level` int(11) unsigned DEFAULT '0' COMMENT '压缩级别',\n" +
" `minLength` json DEFAULT NULL COMMENT '可压缩最小值',\n" +
" `maxLength` json DEFAULT NULL COMMENT '可压缩最大值',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `conds` json DEFAULT NULL COMMENT '条件',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Gzip配置';\n" +
"CREATE TABLE `edgeHTTPHeaderPolicies` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `isOn` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '是否启用',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `addHeaders` json DEFAULT NULL COMMENT '添加的Header',\n" +
" `addTrailers` json DEFAULT NULL COMMENT '添加的Trailers',\n" +
" `setHeaders` json DEFAULT NULL COMMENT '设置Header',\n" +
" `replaceHeaders` json DEFAULT NULL COMMENT '替换Header内容',\n" +
" `expires` json DEFAULT NULL COMMENT 'Expires单独设置',\n" +
" `deleteHeaders` json DEFAULT NULL COMMENT '删除的Headers',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Header定义';\n" +
"CREATE TABLE `edgeHTTPHeaders` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" `templateId` int(11) unsigned DEFAULT '0' COMMENT '模版ID',\n" +
" `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n" +
" `name` varchar(255) DEFAULT NULL COMMENT '名称',\n" +
" `value` varchar(1024) DEFAULT NULL COMMENT '值',\n" +
" `order` int(11) unsigned DEFAULT '0' COMMENT '排序',\n" +
" `status` json DEFAULT NULL COMMENT '状态码设置',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='HTTP Header';\n" +
"CREATE TABLE `edgeHTTPLocations` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `templateId` int(11) unsigned DEFAULT '0' COMMENT '模版ID',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" `parentId` int(11) unsigned DEFAULT '0' COMMENT '父级ID',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `pattern` varchar(1024) DEFAULT NULL COMMENT '匹配规则',\n" +
" `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n" +
" `name` varchar(255) DEFAULT NULL COMMENT '名称',\n" +
" `description` varchar(1024) DEFAULT NULL COMMENT '描述',\n" +
" `webId` int(11) unsigned DEFAULT '0' COMMENT 'Web配置ID',\n" +
" `reverseProxy` json DEFAULT NULL COMMENT '反向代理',\n" +
" `urlPrefix` varchar(1024) DEFAULT NULL COMMENT 'URL前缀',\n" +
" `isBreak` tinyint(1) unsigned DEFAULT '0' COMMENT '是否终止匹配',\n" +
" `conds` json DEFAULT NULL COMMENT '匹配条件',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='路径规则配置';\n" +
"CREATE TABLE `edgeHTTPPages` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" `isOn` tinyint(1) unsigned DEFAULT '0' COMMENT '是否启用',\n" +
" `statusList` json DEFAULT NULL COMMENT '状态列表',\n" +
" `url` varchar(1024) DEFAULT NULL COMMENT '页面URL',\n" +
" `newStatus` int(3) DEFAULT NULL COMMENT '新状态码',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='特殊页面';\n" +
"CREATE TABLE `edgeHTTPRewriteRules` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" `templateId` int(11) unsigned DEFAULT '0' COMMENT '模版ID',\n" +
" `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `pattern` varchar(1024) DEFAULT NULL COMMENT '匹配规则',\n" +
" `replace` varchar(1024) DEFAULT NULL COMMENT '跳转后的地址',\n" +
" `mode` varchar(255) DEFAULT NULL COMMENT '替换模式',\n" +
" `redirectStatus` int(3) unsigned DEFAULT '0' COMMENT '跳转的状态码',\n" +
" `proxyHost` varchar(255) DEFAULT NULL COMMENT '代理的主机名',\n" +
" `isBreak` tinyint(1) unsigned DEFAULT '1' COMMENT '是否终止解析',\n" +
" `withQuery` tinyint(1) unsigned DEFAULT '1' COMMENT '是否保留URI参数',\n" +
" `conds` json DEFAULT NULL COMMENT '匹配条件',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='重写规则';\n" +
"CREATE TABLE `edgeHTTPWebs` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n" +
" `templateId` int(11) unsigned DEFAULT '0' COMMENT '模版ID',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `root` json DEFAULT NULL COMMENT '根目录',\n" +
" `charset` json DEFAULT NULL COMMENT '字符集',\n" +
" `shutdown` json DEFAULT NULL COMMENT '临时关闭页面配置',\n" +
" `pages` json DEFAULT NULL COMMENT '特殊页面',\n" +
" `redirectToHttps` json DEFAULT NULL COMMENT '跳转到HTTPS设置',\n" +
" `indexes` json DEFAULT NULL COMMENT '首页文件列表',\n" +
" `maxRequestBodySize` json DEFAULT NULL COMMENT '最大允许的请求内容尺寸',\n" +
" `requestHeader` json DEFAULT NULL COMMENT '请求Header配置',\n" +
" `responseHeader` json DEFAULT NULL COMMENT '响应Header配置',\n" +
" `accessLog` json DEFAULT NULL COMMENT '访问日志配置',\n" +
" `stat` json DEFAULT NULL COMMENT '统计配置',\n" +
" `gzip` json DEFAULT NULL COMMENT 'Gzip配置',\n" +
" `cache` json DEFAULT NULL COMMENT '缓存配置',\n" +
" `firewall` json DEFAULT NULL COMMENT '防火墙设置',\n" +
" `locations` json DEFAULT NULL COMMENT '路径规则配置',\n" +
" `websocket` json DEFAULT NULL COMMENT 'Websocket设置',\n" +
" `rewriteRules` json DEFAULT NULL COMMENT '重写规则配置',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='HTTP Web';\n" +
"CREATE TABLE `edgeHTTPWebsockets` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n" +
" `handshakeTimeout` json DEFAULT NULL COMMENT '握手超时时间',\n" +
" `allowAllOrigins` tinyint(1) unsigned DEFAULT '1' COMMENT '是否支持所有源',\n" +
" `allowedOrigins` json DEFAULT NULL COMMENT '支持的源域名列表',\n" +
" `requestSameOrigin` tinyint(1) unsigned DEFAULT '1' COMMENT '是否请求一样的Origin',\n" +
" `requestOrigin` varchar(255) DEFAULT NULL COMMENT '请求Origin',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Websocket设置';\n" +
"CREATE TABLE `edgeLogs` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `level` varchar(32) DEFAULT NULL COMMENT '级别',\n" +
" `description` varchar(255) DEFAULT NULL COMMENT '描述',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `action` varchar(255) DEFAULT NULL COMMENT '动作',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" `providerId` int(11) unsigned DEFAULT '0' COMMENT '供应商ID',\n" +
" `ip` varchar(32) DEFAULT NULL COMMENT 'IP地址',\n" +
" `type` varchar(255) DEFAULT 'admin' COMMENT '类型admin, user',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='操作日志';\n" +
"CREATE TABLE `edgeNodeClusters` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" `name` varchar(255) DEFAULT NULL COMMENT '名称',\n" +
" `useAllAPINodes` tinyint(1) unsigned DEFAULT '1' COMMENT '是否使用所有API节点',\n" +
" `apiNodes` json DEFAULT NULL COMMENT '使用的API节点',\n" +
" `installDir` varchar(512) DEFAULT NULL COMMENT '安装目录',\n" +
" `order` int(11) unsigned DEFAULT '0' COMMENT '排序',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `grantId` int(11) unsigned DEFAULT '0' COMMENT '默认认证方式',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='节点集群';\n" +
"CREATE TABLE `edgeNodeGrants` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `name` varchar(255) DEFAULT NULL COMMENT '名称',\n" +
" `method` varchar(64) DEFAULT NULL COMMENT '登录方式',\n" +
" `username` varchar(255) DEFAULT NULL COMMENT '用户名',\n" +
" `password` varchar(255) DEFAULT NULL COMMENT '密码',\n" +
" `su` tinyint(1) unsigned DEFAULT '1' COMMENT '是否需要su',\n" +
" `privateKey` varchar(4096) DEFAULT NULL COMMENT '密钥',\n" +
" `description` varchar(255) DEFAULT NULL COMMENT '备注',\n" +
" `nodeId` int(11) unsigned DEFAULT '0' COMMENT '专有节点',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='节点授权';\n" +
"CREATE TABLE `edgeNodeGroups` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `name` varchar(255) DEFAULT NULL COMMENT '名称',\n" +
" `order` int(11) unsigned DEFAULT '0' COMMENT '排序',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='节点分组';\n" +
"CREATE TABLE `edgeNodeIPAddresses` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `nodeId` int(11) unsigned DEFAULT '0' COMMENT '节点ID',\n" +
" `name` varchar(255) DEFAULT NULL COMMENT '名称',\n" +
" `ip` varchar(128) DEFAULT NULL COMMENT 'IP地址',\n" +
" `description` varchar(255) DEFAULT NULL COMMENT '描述',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" `order` int(11) unsigned DEFAULT '0' COMMENT '排序',\n" +
" PRIMARY KEY (`id`),\n" +
" KEY `nodeId` (`nodeId`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='节点IP地址';\n" +
"CREATE TABLE `edgeNodeLogins` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `nodeId` int(11) unsigned DEFAULT '0' COMMENT '节点ID',\n" +
" `name` varchar(255) DEFAULT NULL COMMENT '名称',\n" +
" `type` varchar(255) DEFAULT NULL COMMENT '类型ssh,agent',\n" +
" `params` json DEFAULT NULL COMMENT '配置参数',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" PRIMARY KEY (`id`),\n" +
" KEY `nodeId` (`nodeId`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='节点登录信息';\n" +
"CREATE TABLE `edgeNodeLogs` (\n" +
" `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `role` varchar(64) DEFAULT NULL COMMENT '节点角色',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `tag` varchar(255) DEFAULT NULL COMMENT '标签',\n" +
" `description` varchar(1024) DEFAULT NULL COMMENT '描述',\n" +
" `level` varchar(32) DEFAULT NULL COMMENT '级别',\n" +
" `nodeId` int(11) unsigned DEFAULT '0' COMMENT '节点ID',\n" +
" `day` varchar(8) DEFAULT NULL COMMENT '日期',\n" +
" PRIMARY KEY (`id`),\n" +
" KEY `level` (`level`),\n" +
" KEY `day` (`day`),\n" +
" KEY `role_nodeId` (`role`,`nodeId`) USING BTREE\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='节点日志';\n" +
"CREATE TABLE `edgeNodeRegions` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `name` varchar(255) DEFAULT NULL COMMENT '名称',\n" +
" `order` int(11) unsigned DEFAULT '0' COMMENT '排序',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='节点区域';\n" +
"CREATE TABLE `edgeNodes` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n" +
" `uniqueId` varchar(32) DEFAULT NULL COMMENT '节点ID',\n" +
" `secret` varchar(32) DEFAULT NULL COMMENT '密钥',\n" +
" `name` varchar(255) DEFAULT NULL COMMENT '节点名',\n" +
" `code` varchar(255) DEFAULT NULL COMMENT '代号',\n" +
" `clusterId` int(11) unsigned DEFAULT '0' COMMENT '集群ID',\n" +
" `regionId` int(11) unsigned DEFAULT '0' COMMENT '区域ID',\n" +
" `groupId` int(11) unsigned DEFAULT '0' COMMENT '分组ID',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `status` json DEFAULT NULL COMMENT '最新的状态',\n" +
" `version` int(11) unsigned DEFAULT '0' COMMENT '当前版本号',\n" +
" `latestVersion` int(11) unsigned DEFAULT '0' COMMENT '最后版本号',\n" +
" `installDir` varchar(512) DEFAULT NULL COMMENT '安装目录',\n" +
" `isInstalled` tinyint(1) unsigned DEFAULT '0' COMMENT '是否已安装',\n" +
" `installStatus` json DEFAULT NULL COMMENT '安装状态',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" `connectedAPINodes` json DEFAULT NULL COMMENT '当前连接的API节点',\n" +
" `maxCPU` int(4) unsigned DEFAULT '0' COMMENT '可以使用的最多CPU',\n" +
" PRIMARY KEY (`id`),\n" +
" KEY `uniqueId` (`uniqueId`),\n" +
" KEY `clusterId` (`clusterId`),\n" +
" KEY `groupId` (`groupId`),\n" +
" KEY `regionId` (`regionId`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='节点';\n" +
"CREATE TABLE `edgeOrigins` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n" +
" `name` varchar(255) DEFAULT NULL COMMENT '名称',\n" +
" `version` int(11) unsigned DEFAULT '0' COMMENT '版本',\n" +
" `addr` json DEFAULT NULL COMMENT '地址',\n" +
" `description` varchar(512) DEFAULT NULL COMMENT '描述',\n" +
" `code` varchar(255) DEFAULT NULL COMMENT '代号',\n" +
" `weight` int(11) unsigned DEFAULT '0' COMMENT '权重',\n" +
" `connTimeout` json DEFAULT NULL COMMENT '连接超时',\n" +
" `readTimeout` json DEFAULT NULL COMMENT '读超时',\n" +
" `idleTimeout` json DEFAULT NULL COMMENT '空闲连接超时',\n" +
" `maxFails` int(11) unsigned DEFAULT '0' COMMENT '最多失败次数',\n" +
" `maxConns` int(11) unsigned DEFAULT '0' COMMENT '最大并发连接数',\n" +
" `maxIdleConns` int(11) unsigned DEFAULT '0' COMMENT '最多空闲连接数',\n" +
" `httpRequestURI` varchar(1024) DEFAULT NULL COMMENT '转发后的请求URI',\n" +
" `httpRequestHeader` json DEFAULT NULL COMMENT '请求Header配置',\n" +
" `httpResponseHeader` json DEFAULT NULL COMMENT '响应Header配置',\n" +
" `host` varchar(255) DEFAULT NULL COMMENT '自定义主机名',\n" +
" `healthCheck` json DEFAULT NULL COMMENT '健康检查设置',\n" +
" `cert` json DEFAULT NULL COMMENT '证书设置',\n" +
" `ftp` json DEFAULT NULL COMMENT 'FTP相关设置',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='源站';\n" +
"CREATE TABLE `edgeProviders` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `username` varchar(64) DEFAULT NULL COMMENT '用户名',\n" +
" `password` varchar(32) DEFAULT NULL COMMENT '密码',\n" +
" `fullname` varchar(64) DEFAULT NULL COMMENT '真实姓名',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `updatedAt` bigint(11) unsigned DEFAULT '0' COMMENT '修改时间',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='供应商';\n" +
"CREATE TABLE `edgeReverseProxies` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" `templateId` int(11) unsigned DEFAULT '0' COMMENT '模版ID',\n" +
" `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n" +
" `scheduling` json DEFAULT NULL COMMENT '调度算法',\n" +
" `primaryOrigins` json DEFAULT NULL COMMENT '主要源站',\n" +
" `backupOrigins` json DEFAULT NULL COMMENT '备用源站',\n" +
" `stripPrefix` varchar(255) DEFAULT NULL COMMENT '去除URL前缀',\n" +
" `requestHost` varchar(255) DEFAULT NULL COMMENT '请求Host',\n" +
" `requestURI` varchar(1024) DEFAULT NULL COMMENT '请求URI',\n" +
" `autoFlush` tinyint(1) unsigned DEFAULT '0' COMMENT '是否自动刷新缓冲区',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='反向代理配置';\n" +
"CREATE TABLE `edgeSSLCertGroups` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" `name` varchar(255) DEFAULT NULL COMMENT '分组名',\n" +
" `order` int(11) unsigned DEFAULT '0' COMMENT '分组排序',\n" +
" `state` tinyint(1) unsigned DEFAULT '0' COMMENT '状态',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='证书分组';\n" +
"CREATE TABLE `edgeSSLCerts` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `updatedAt` bigint(11) unsigned DEFAULT '0' COMMENT '修改时间',\n" +
" `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n" +
" `name` varchar(255) DEFAULT NULL COMMENT '证书名',\n" +
" `description` varchar(1024) DEFAULT NULL COMMENT '描述',\n" +
" `certData` blob COMMENT '证书内容',\n" +
" `keyData` blob COMMENT '密钥内容',\n" +
" `serverName` varchar(255) DEFAULT NULL COMMENT '证书使用的主机名',\n" +
" `isCA` tinyint(1) unsigned DEFAULT '0' COMMENT '是否为CA证书',\n" +
" `groupIds` json DEFAULT NULL COMMENT '证书分组',\n" +
" `timeBeginAt` bigint(11) unsigned DEFAULT '0' COMMENT '开始时间',\n" +
" `timeEndAt` bigint(11) unsigned DEFAULT '0' COMMENT '结束时间',\n" +
" `dnsNames` json DEFAULT NULL COMMENT 'DNS名称列表',\n" +
" `commonNames` json DEFAULT NULL COMMENT '发行单位列表',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='SSL证书';\n" +
"CREATE TABLE `edgeSSLPolicies` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n" +
" `certs` json DEFAULT NULL COMMENT '证书列表',\n" +
" `clientCACerts` json DEFAULT NULL COMMENT '客户端证书',\n" +
" `clientAuthType` int(11) unsigned DEFAULT '0' COMMENT '客户端认证类型',\n" +
" `minVersion` varchar(32) DEFAULT NULL COMMENT '支持的SSL最小版本',\n" +
" `cipherSuitesIsOn` tinyint(1) unsigned DEFAULT '0' COMMENT '是否自定义加密算法套件',\n" +
" `cipherSuites` json DEFAULT NULL COMMENT '加密算法套件',\n" +
" `hsts` json DEFAULT NULL COMMENT 'HSTS设置',\n" +
" `http2Enabled` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用HTTP/2',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='SSL配置策略';\n" +
"CREATE TABLE `edgeServerGroups` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" `name` varchar(255) DEFAULT NULL COMMENT '名称',\n" +
" `order` int(11) unsigned DEFAULT '0' COMMENT '排序',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='服务分组';\n" +
"CREATE TABLE `edgeServers` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n" +
" `type` varchar(64) DEFAULT NULL COMMENT '服务类型',\n" +
" `name` varchar(255) DEFAULT NULL COMMENT '名称',\n" +
" `description` varchar(512) DEFAULT NULL COMMENT '描述',\n" +
" `serverNames` json DEFAULT NULL COMMENT '域名列表',\n" +
" `http` json DEFAULT NULL COMMENT 'HTTP配置',\n" +
" `https` json DEFAULT NULL COMMENT 'HTTPS配置',\n" +
" `tcp` json DEFAULT NULL COMMENT 'TCP配置',\n" +
" `tls` json DEFAULT NULL COMMENT 'TLS配置',\n" +
" `unix` json DEFAULT NULL COMMENT 'Unix配置',\n" +
" `udp` json DEFAULT NULL COMMENT 'UDP配置',\n" +
" `webId` int(11) unsigned DEFAULT '0' COMMENT 'WEB配置',\n" +
" `reverseProxy` json DEFAULT NULL COMMENT '反向代理配置',\n" +
" `groupIds` json DEFAULT NULL COMMENT '分组ID列表',\n" +
" `config` json DEFAULT NULL COMMENT '服务配置,自动生成',\n" +
" `configMd5` varchar(32) DEFAULT NULL COMMENT 'Md5',\n" +
" `clusterId` int(11) unsigned DEFAULT '0' COMMENT '集群ID',\n" +
" `includeNodes` json DEFAULT NULL COMMENT '部署条件',\n" +
" `excludeNodes` json DEFAULT NULL COMMENT '节点排除条件',\n" +
" `version` int(11) unsigned DEFAULT '0' COMMENT '版本号',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" PRIMARY KEY (`id`),\n" +
" KEY `userId` (`userId`),\n" +
" KEY `adminId` (`adminId`),\n" +
" KEY `isUpdating_state` (`state`) USING BTREE\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='服务';\n" +
"CREATE TABLE `edgeSysEvents` (\n" +
" `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `type` varchar(255) DEFAULT NULL COMMENT '类型',\n" +
" `params` json DEFAULT NULL COMMENT '参数',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统事件';\n" +
"CREATE TABLE `edgeSysLockers` (\n" +
" `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `key` varchar(255) DEFAULT NULL COMMENT '键值',\n" +
" `version` bigint(20) unsigned DEFAULT '0' COMMENT '版本号',\n" +
" `timeoutAt` bigint(11) unsigned DEFAULT '0' COMMENT '超时时间',\n" +
" PRIMARY KEY (`id`),\n" +
" UNIQUE KEY `key` (`key`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='并发锁';\n" +
"CREATE TABLE `edgeSysSettings` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" `code` varchar(255) DEFAULT NULL COMMENT '代号',\n" +
" `value` json DEFAULT NULL COMMENT '配置值',\n" +
" PRIMARY KEY (`id`),\n" +
" UNIQUE KEY `code` (`code`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统配置';\n" +
"CREATE TABLE `edgeTCPFirewallPolicies` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `adminId` int(11) DEFAULT NULL COMMENT '管理员ID',\n" +
" `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n" +
" `templateId` int(11) unsigned DEFAULT '0' COMMENT '模版ID',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='TCP防火墙';\n" +
"CREATE TABLE `edgeUsers` (\n" +
" `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `username` varchar(64) DEFAULT NULL COMMENT '用户名',\n" +
" `password` varchar(32) DEFAULT NULL COMMENT '密码',\n" +
" `fullname` varchar(64) DEFAULT NULL COMMENT '真实姓名',\n" +
" `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n" +
" `updatedAt` bigint(11) unsigned DEFAULT '0' COMMENT '修改时间',\n" +
" `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户';\n" +
"CREATE TABLE `edgeVersions` (\n" +
" `id` bigint(16) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n" +
" `version` varchar(64) DEFAULT NULL,\n" +
" PRIMARY KEY (`id`)\n" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='数据库结构版本';\n" +
"\n"

View File

@@ -1,6 +0,0 @@
// generated
package sqls
var SQLVersions = []map[string]string{
{"version": "full", "sql": SQL_full},
}