github.com/polarismesh/polaris@v1.17.8/store/mysql/scripts/delta/v1_6_0-v1_7_0.sql (about) 1 /* 2 * Tencent is pleased to support the open source community by making Polaris available. 3 * 4 * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 * 6 * Licensed under the BSD 3-Clause License (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * https://opensource.org/licenses/BSD-3-Clause 11 * 12 * Unless required by applicable law or agreed to in writing, software distributed 13 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 * specific language governing permissions and limitations under the License. 16 */ 17 -- 18 -- Database: `polaris_server` 19 -- 20 CREATE 21 DATABASE IF NOT EXISTS `polaris_server` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin; 22 23 USE 24 `polaris_server`; 25 26 INSERT INTO `service` (`id`, 27 `name`, 28 `namespace`, 29 `comment`, 30 `business`, 31 `token`, 32 `revision`, 33 `owner`, 34 `flag`, 35 `ctime`, 36 `mtime`) 37 VALUES ('e6542db1a2cc846c1866010b40b7f51f', 38 'polaris.config', 39 'Polaris', 40 'polaris config service', 41 'polaris', 42 'c874d9a0a4b45c82c93e6bf285518c7b', 43 '769ec01f58875088faf2cb9e44a4b2d2', 44 'polaris', 45 0, 46 '2021-09-06 07:55:07', 47 '2021-09-06 07:55:11'); 48 49 -- Support polarismesh Authentication Ability 50 -- User data 51 CREATE TABLE `user` 52 ( 53 `id` VARCHAR(128) NOT NULL comment 'User ID', 54 `name` VARCHAR(100) NOT NULL comment 'user name', 55 `password` VARCHAR(100) NOT NULL comment 'user password', 56 `owner` VARCHAR(128) NOT NULL comment 'Main account ID', 57 `source` VARCHAR(32) NOT NULL comment 'Account source', 58 `mobile` VARCHAR(12) NOT NULL DEFAULT '' comment 'Account mobile phone number', 59 `email` VARCHAR(64) NOT NULL DEFAULT '' comment 'Account mailbox', 60 `token` VARCHAR(255) NOT NULL comment 'The token information owned by the account can be used for SDK access authentication', 61 `token_enable` tinyint(4) NOT NULL DEFAULT 1, 62 `user_type` int NOT NULL DEFAULT 20 comment 'Account type, 0 is the admin super account, 20 is the primary account, 50 for the child account', 63 `comment` VARCHAR(255) NOT NULL comment 'describe', 64 `flag` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Whether the rules are valid, 0 is valid, 1 is invalid, it is deleted', 65 `ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment 'Create time', 66 `mtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment 'Last updated time', 67 PRIMARY KEY (`id`), 68 UNIQUE KEY (`name`, `owner`), 69 KEY `owner` (`owner`), 70 KEY `mtime` (`mtime`) 71 ) ENGINE = InnoDB; 72 73 -- user group 74 CREATE TABLE `user_group` 75 ( 76 `id` VARCHAR(128) NOT NULL comment 'User group ID', 77 `name` VARCHAR(100) NOT NULL comment 'User group name', 78 `owner` VARCHAR(128) NOT NULL comment 'The main account ID of the user group', 79 `token` VARCHAR(255) NOT NULL comment 'TOKEN information of this user group', 80 `comment` VARCHAR(255) NOT NULL comment 'Description', 81 `token_enable` tinyint(4) NOT NULL DEFAULT 1, 82 `flag` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Whether the rules are valid, 0 is valid, 1 is invalid, it is deleted', 83 `ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment 'Create time', 84 `mtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment 'Last updated time', 85 PRIMARY KEY (`id`), 86 UNIQUE KEY (`name`, `owner`), 87 KEY `owner` (`owner`), 88 KEY `mtime` (`mtime`) 89 ) ENGINE = InnoDB; 90 91 -- Users of users and user groups 92 CREATE TABLE `user_group_relation` 93 ( 94 `user_id` VARCHAR(128) NOT NULL comment 'User ID', 95 `group_id` VARCHAR(128) NOT NULL comment 'User group ID', 96 `ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment 'Create time', 97 `mtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment 'Last updated time', 98 PRIMARY KEY (`user_id`, `group_id`), 99 KEY `mtime` (`mtime`) 100 ) ENGINE = InnoDB; 101 102 -- Subject information of authentication strategy 103 CREATE TABLE `auth_strategy` 104 ( 105 `id` VARCHAR(128) NOT NULL comment 'Strategy ID', 106 `name` VARCHAR(100) NOT NULL comment 'Policy name', 107 `action` VARCHAR(32) NOT NULL comment 'Read and write permission for this policy, only_read = 0, read_write = 1', 108 `owner` VARCHAR(128) NOT NULL comment 'The account ID to which this policy is', 109 `comment` VARCHAR(255) NOT NULL comment 'describe', 110 `default` tinyint(4) NOT NULL DEFAULT '0', 111 `revision` VARCHAR(128) NOT NULL comment 'Authentication rule version', 112 `flag` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'Whether the rules are valid, 0 is valid, 1 is invalid, it is deleted', 113 `ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment 'Create time', 114 `mtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment 'Last updated time', 115 PRIMARY KEY (`id`), 116 UNIQUE KEY (`name`, `owner`), 117 KEY `owner` (`owner`), 118 KEY `mtime` (`mtime`) 119 ) ENGINE = InnoDB; 120 121 -- Member information, users and user groups in authentication strategies 122 CREATE TABLE `auth_principal` 123 ( 124 `strategy_id` VARCHAR(128) NOT NULL comment 'Strategy ID', 125 `principal_id` VARCHAR(128) NOT NULL comment 'Principal ID', 126 `principal_role` int NOT NULL comment 'PRINCIPAL type, 1 is User, 2 is Group', 127 PRIMARY KEY (`strategy_id`, `principal_id`, `principal_role`) 128 ) ENGINE = InnoDB; 129 130 -- Resource information record involved in the authentication strategy 131 CREATE TABLE `auth_strategy_resource` 132 ( 133 `strategy_id` VARCHAR(128) NOT NULL comment 'Strategy ID', 134 `res_type` int NOT NULL comment 'Resource Type, Namespaces = 0, Service = 1, configgroups = 2', 135 `res_id` VARCHAR(128) NOT NULL comment 'Resource ID', 136 `ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP comment 'Create time', 137 `mtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment 'Last updated time', 138 PRIMARY KEY (`strategy_id`, `res_type`, `res_id`), 139 KEY `mtime` (`mtime`) 140 ) ENGINE = InnoDB; 141 142 -- Create a default master account, password is Polarismesh @ 2021 143 INSERT INTO `user` (`id`, 144 `name`, 145 `password`, 146 `source`, 147 `token`, 148 `token_enable`, 149 `user_type`, 150 `comment`, 151 `owner`) 152 VALUES ('65e4789a6d5b49669adf1e9e8387549c', 153 'polaris', 154 '$2a$10$3izWuZtE5SBdAtSZci.gs.iZ2pAn9I8hEqYrC6gwJp1dyjqQnrrum', 155 'Polaris', 156 'nu/0WRA4EqSR1FagrjRj0fZwPXuGlMpX+zCuWu4uMqy8xr1vRjisSbA25aAC3mtU8MeeRsKhQiDAynUR09I=', 157 1, 158 20, 159 'default polaris admin account', 160 ''); 161 162 -- Permissions policy inserted into Polaris-Admin 163 INSERT INTO `auth_strategy`(`id`, 164 `name`, 165 `action`, 166 `owner`, 167 `comment`, 168 `default`, 169 `revision`, 170 `flag`, 171 `ctime`, 172 `mtime`) 173 VALUES ('fbca9bfa04ae4ead86e1ecf5811e32a9', 174 '(用户) polaris的默认策略', 175 'READ_WRITE', 176 '65e4789a6d5b49669adf1e9e8387549c', 177 'default admin', 178 1, 179 'fbca9bfa04ae4ead86e1ecf5811e32a9', 180 0, 181 sysdate(), 182 sysdate()); 183 184 -- Sport rules inserted into Polaris-Admin to access 185 INSERT INTO `auth_strategy_resource`(`strategy_id`, 186 `res_type`, 187 `res_id`, 188 `ctime`, 189 `mtime`) 190 VALUES ('fbca9bfa04ae4ead86e1ecf5811e32a9', 191 0, 192 '*', 193 sysdate(), 194 sysdate()), 195 ('fbca9bfa04ae4ead86e1ecf5811e32a9', 196 1, 197 '*', 198 sysdate(), 199 sysdate()), 200 ('fbca9bfa04ae4ead86e1ecf5811e32a9', 201 2, 202 '*', 203 sysdate(), 204 sysdate()); 205 206 -- Insert permission policies and association relationships for Polaris-Admin accounts 207 INSERT INTO auth_principal(`strategy_id`, `principal_id`, `principal_role`) VALUE ( 208 'fbca9bfa04ae4ead86e1ecf5811e32a9', 209 '65e4789a6d5b49669adf1e9e8387549c', 210 1 211 ); 212 213 -- -------------------------------------------------------- 214 -- 215 -- Table structure `config_file` 216 -- 217 CREATE TABLE `config_file` 218 ( 219 `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', 220 `namespace` varchar(64) NOT NULL COMMENT '所属的namespace', 221 `group` varchar(128) NOT NULL DEFAULT '' COMMENT '所属的文件组', 222 `name` varchar(128) NOT NULL COMMENT '配置文件名', 223 `content` longtext NOT NULL COMMENT '文件内容', 224 `format` varchar(16) DEFAULT 'text' COMMENT '文件格式,枚举值', 225 `comment` varchar(512) DEFAULT NULL COMMENT '备注信息', 226 `flag` tinyint(4) NOT NULL DEFAULT '0' COMMENT '软删除标记位', 227 `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 228 `create_by` varchar(32) DEFAULT NULL COMMENT '创建人', 229 `modify_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间', 230 `modify_by` varchar(32) DEFAULT NULL COMMENT '最后更新人', 231 PRIMARY KEY (`id`), 232 UNIQUE KEY `uk_file` (`namespace`, `group`, `name`) 233 ) ENGINE = InnoDB 234 AUTO_INCREMENT = 1 COMMENT = '配置文件表'; 235 236 -- -------------------------------------------------------- 237 -- 238 -- Table structure `config_file_group` 239 -- 240 CREATE TABLE `config_file_group` 241 ( 242 `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', 243 `name` varchar(128) NOT NULL COMMENT '配置文件分组名', 244 `namespace` varchar(64) NOT NULL COMMENT '所属的namespace', 245 `comment` varchar(512) DEFAULT NULL COMMENT '备注信息', 246 `owner` varchar(1024) DEFAULT NULL COMMENT '负责人', 247 `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 248 `create_by` varchar(32) DEFAULT NULL COMMENT '创建人', 249 `modify_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间', 250 `modify_by` varchar(32) DEFAULT NULL COMMENT '最后更新人', 251 PRIMARY KEY (`id`), 252 UNIQUE KEY `uk_name` (`namespace`, `name`) 253 ) ENGINE = InnoDB 254 AUTO_INCREMENT = 1 COMMENT = '配置文件组表'; 255 256 -- -------------------------------------------------------- 257 -- 258 -- Table structure `config_file_release` 259 -- 260 CREATE TABLE `config_file_release` 261 ( 262 `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', 263 `name` varchar(128) DEFAULT NULL COMMENT '发布标题', 264 `namespace` varchar(64) NOT NULL COMMENT '所属的namespace', 265 `group` varchar(128) NOT NULL COMMENT '所属的文件组', 266 `file_name` varchar(128) NOT NULL COMMENT '配置文件名', 267 `content` longtext NOT NULL COMMENT '文件内容', 268 `comment` varchar(512) DEFAULT NULL COMMENT '备注信息', 269 `md5` varchar(128) NOT NULL COMMENT 'content的md5值', 270 `version` int(11) NOT NULL COMMENT '版本号,每次发布自增1', 271 `flag` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否被删除', 272 `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 273 `create_by` varchar(32) DEFAULT NULL COMMENT '创建人', 274 `modify_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间', 275 `modify_by` varchar(32) DEFAULT NULL COMMENT '最后更新人', 276 PRIMARY KEY (`id`), 277 UNIQUE KEY `uk_file` (`namespace`, `group`, `file_name`), 278 KEY `idx_modify_time` (`modify_time`) 279 ) ENGINE = InnoDB 280 AUTO_INCREMENT = 1 COMMENT = '配置文件发布表'; 281 282 -- -------------------------------------------------------- 283 -- 284 -- Table structure `config_file_release_history` 285 -- 286 CREATE TABLE `config_file_release_history` 287 ( 288 `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', 289 `name` varchar(64) DEFAULT '' COMMENT '发布名称', 290 `namespace` varchar(64) NOT NULL COMMENT '所属的namespace', 291 `group` varchar(128) NOT NULL COMMENT '所属的文件组', 292 `file_name` varchar(128) NOT NULL COMMENT '配置文件名', 293 `content` longtext NOT NULL COMMENT '文件内容', 294 `format` varchar(16) DEFAULT 'text' COMMENT '文件格式', 295 `tags` varchar(2048) DEFAULT '' COMMENT '文件标签', 296 `comment` varchar(512) DEFAULT NULL COMMENT '备注信息', 297 `md5` varchar(128) NOT NULL COMMENT 'content的md5值', 298 `type` varchar(32) NOT NULL COMMENT '发布类型,例如全量发布、灰度发布', 299 `status` varchar(16) NOT NULL DEFAULT 'success' COMMENT '发布状态,success表示成功,fail 表示失败', 300 `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 301 `create_by` varchar(32) DEFAULT NULL COMMENT '创建人', 302 `modify_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间', 303 `modify_by` varchar(32) DEFAULT NULL COMMENT '最后更新人', 304 PRIMARY KEY (`id`), 305 KEY `idx_file` (`namespace`, `group`, `file_name`) 306 ) ENGINE = InnoDB 307 AUTO_INCREMENT = 1 COMMENT = '配置文件发布历史表'; 308 309 -- -------------------------------------------------------- 310 -- 311 -- Table structure `config_file_tag` 312 -- 313 CREATE TABLE `config_file_tag` 314 ( 315 `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', 316 `key` varchar(128) NOT NULL COMMENT 'tag 的键', 317 `Value` varchar(128) NOT NULL COMMENT 'tag 的值', 318 `namespace` varchar(64) NOT NULL COMMENT '所属的namespace', 319 `group` varchar(128) NOT NULL DEFAULT '' COMMENT '所属的文件组', 320 `file_name` varchar(128) NOT NULL COMMENT '配置文件名', 321 `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 322 `create_by` varchar(32) DEFAULT NULL COMMENT '创建人', 323 `modify_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间', 324 `modify_by` varchar(32) DEFAULT NULL COMMENT '最后更新人', 325 PRIMARY KEY (`id`), 326 UNIQUE KEY `uk_tag` ( 327 `key`, 328 `Value`, 329 `namespace`, 330 `group`, 331 `file_name` 332 ), 333 KEY `idx_file` (`namespace`, `group`, `file_name`) 334 ) ENGINE = InnoDB 335 AUTO_INCREMENT = 1 COMMENT = '配置文件标签表';