Files
EdgeAPI/internal/setup/sql.go

16 lines
2.0 MiB
Go
Raw Normal View History

2020-11-16 23:30:47 +08:00
package setup
import (
"encoding/json"
"github.com/iwind/TeaGo/logs"
)
// 最新版本的数据库SQL语句用来对比并升级已有的数据库
// 由 sql-dump/main.go 自动生成
2020-11-16 23:30:47 +08:00
func init() {
2022-11-06 19:13:47 +08:00
err := json.Unmarshal([]byte("{\"tables\":[{\"name\":\"edgeHTTPRewriteRules\",\"engine\":\"InnoDB\",\"charset\":\"utf8mb4_general_ci\",\"definition\":\"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='重写规则'\",\"fields\":[{\"name\":\"id\",\"definition\":\"int(11) unsigned auto_increment COMMENT 'ID'\"},{\"name\":\"adminId\",\"definition\":\"int(11) unsigned DEFAULT '0' COMMENT '管理员ID'\"},{\"name\":\"userId\",\"definition\":\"int(11) unsigned DEFAULT '0' COMMENT '用户ID'\"},{\"name\":\"templateId\",\"definition\":\"int(11) unsigned DEFAULT '0' COMMENT '模版ID'\"},{\"name\":\"isOn\",\"definition\":\"tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用'\"},{\"name\":\"state\",\"definition\":\"tinyint(1) unsigned DEFAULT '1' COMMENT '状态'\"},{\"name\":\"createdAt\",\"definition\":\"bigint(11) unsigned DEFAULT '0' COMMENT '创建时间'\"},{\"name\":\"pattern\",\"definition\":\"varchar(1024) COMMENT '匹配规则'\"},{\"name\":\"replace\",\"definition\":\"varchar(1024) COMMENT '跳转后的地址'\"},{\"name\":\"mode\",\"definition\":\"varchar(255) COMMENT '替换模式'\"},{\"name\":\"redirectStatus\",\"definition\":\"int(3) unsigned DEFAULT '0' COMMENT '跳转的状态码'\"},{\"name\":\"proxyHost\",\"definition\":\"varchar(255) COMMENT '代理的主机名'\"},{\"name\":\"isBreak\",\"definition\":\"tinyint(1) unsigned DEFAULT '1' COMMENT '是否终止解析'\"},{\"name\":\"withQuery\",\"definition\":\"tinyint(1) unsigned DEFAULT '1' COMMENT '是否保留URI参数'\"},{\"name\":\"conds\",\"definition\":\"json COMMENT '匹配条件'\"}],\"indexes\":[{\"name\":\"PRIMARY\",\"definition\":\"UNIQUE KEY `PRIMARY` (`id`) USING BTREE\"}],\"records\":[]},{\"name\":\"edgeUserBandwidthStats_16\",\"engine\":\"InnoDB\",\"charset\":\"utf8mb4_general_ci\",\"definition\":\"CREATE TABLE `edgeUserBandwidthStats_16` (\\n `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\\n `userId` bigint(20) unsigned DEFAULT '0' COMMENT '用户ID',\\n `day` varchar(8) DEFAULT NULL COMMENT '日期YYYYMMDD',\\n `timeAt` varchar(4) DEFAULT NULL COMMENT '时间点HHII',\\n `bytes` bigint(20) unsigned DEFAULT '0' COMMENT '带宽',\\n `regionId` int(11) unsigned DEFAULT '0' COMMENT '区域ID',\\n PRIMARY KEY (`id`),\\n UNIQUE KEY `user_day_time_region` (`userId`,`day`,`timeAt`,`regionId`) USING BTREE\\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户月带宽峰值'\",\"fields\":[{\"name\":\"id\",\"definition\":\"bigint(20) unsigned auto_increment COMMENT 'ID'\"},{\"name\":\"userId\",\"definition\":\"bigint(20) unsigned DEFAULT '0' COMMENT '用户ID'\"},{\"name\":\"day\",\"definition\":\"varchar(8) COMMENT '日期YYYYMMDD'\"},{\"name\":\"timeAt\",\"definition\":\"varchar(4) COMMENT '时间点HHII'\"},{\"name\":\"bytes\",\"definition\":\"bigint(20) unsigned DEFAULT '0' COMMENT '带宽'\"},{\"name\":\"regionId\",\"definition\":\"int(11) unsigned DEFAULT '0' COMMENT '区域ID'\"}],\"indexes\":[{\"name\":\"PRIMARY\",\"definition\":\"UNIQUE KEY `PRIMARY` (`id`
2020-11-16 23:30:47 +08:00
if err != nil {
logs.Println("[ERROR]load sql failed: " + err.Error())
}
}