mysql-schema.sql 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /*
  2. * Copyright 1999-2018 Alibaba Group Holding Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /******************************************/
  17. /* 表名称 = config_info */
  18. /******************************************/
  19. CREATE TABLE `config_info` (
  20. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  21. `data_id` varchar(255) NOT NULL COMMENT 'data_id',
  22. `group_id` varchar(128) DEFAULT NULL COMMENT 'group_id',
  23. `content` longtext NOT NULL COMMENT 'content',
  24. `md5` varchar(32) DEFAULT NULL COMMENT 'md5',
  25. `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  26. `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  27. `src_user` text COMMENT 'source user',
  28. `src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip',
  29. `app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
  30. `tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
  31. `c_desc` varchar(256) DEFAULT NULL COMMENT 'configuration description',
  32. `c_use` varchar(64) DEFAULT NULL COMMENT 'configuration usage',
  33. `effect` varchar(64) DEFAULT NULL COMMENT '配置生效的描述',
  34. `type` varchar(64) DEFAULT NULL COMMENT '配置的类型',
  35. `c_schema` text COMMENT '配置的模式',
  36. `encrypted_data_key` text NOT NULL COMMENT '密钥',
  37. PRIMARY KEY (`id`),
  38. UNIQUE KEY `uk_configinfo_datagrouptenant` (`data_id`,`group_id`,`tenant_id`)
  39. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info';
  40. /******************************************/
  41. /* 表名称 = config_info_aggr */
  42. /******************************************/
  43. CREATE TABLE `config_info_aggr` (
  44. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  45. `data_id` varchar(255) NOT NULL COMMENT 'data_id',
  46. `group_id` varchar(128) NOT NULL COMMENT 'group_id',
  47. `datum_id` varchar(255) NOT NULL COMMENT 'datum_id',
  48. `content` longtext NOT NULL COMMENT '内容',
  49. `gmt_modified` datetime NOT NULL COMMENT '修改时间',
  50. `app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
  51. `tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
  52. PRIMARY KEY (`id`),
  53. UNIQUE KEY `uk_configinfoaggr_datagrouptenantdatum` (`data_id`,`group_id`,`tenant_id`,`datum_id`)
  54. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='增加租户字段';
  55. /******************************************/
  56. /* 表名称 = config_info_beta */
  57. /******************************************/
  58. CREATE TABLE `config_info_beta` (
  59. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  60. `data_id` varchar(255) NOT NULL COMMENT 'data_id',
  61. `group_id` varchar(128) NOT NULL COMMENT 'group_id',
  62. `app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
  63. `content` longtext NOT NULL COMMENT 'content',
  64. `beta_ips` varchar(1024) DEFAULT NULL COMMENT 'betaIps',
  65. `md5` varchar(32) DEFAULT NULL COMMENT 'md5',
  66. `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  67. `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  68. `src_user` text COMMENT 'source user',
  69. `src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip',
  70. `tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
  71. `encrypted_data_key` text NOT NULL COMMENT '密钥',
  72. PRIMARY KEY (`id`),
  73. UNIQUE KEY `uk_configinfobeta_datagrouptenant` (`data_id`,`group_id`,`tenant_id`)
  74. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info_beta';
  75. /******************************************/
  76. /* 表名称 = config_info_tag */
  77. /******************************************/
  78. CREATE TABLE `config_info_tag` (
  79. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  80. `data_id` varchar(255) NOT NULL COMMENT 'data_id',
  81. `group_id` varchar(128) NOT NULL COMMENT 'group_id',
  82. `tenant_id` varchar(128) DEFAULT '' COMMENT 'tenant_id',
  83. `tag_id` varchar(128) NOT NULL COMMENT 'tag_id',
  84. `app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
  85. `content` longtext NOT NULL COMMENT 'content',
  86. `md5` varchar(32) DEFAULT NULL COMMENT 'md5',
  87. `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  88. `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  89. `src_user` text COMMENT 'source user',
  90. `src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip',
  91. PRIMARY KEY (`id`),
  92. UNIQUE KEY `uk_configinfotag_datagrouptenanttag` (`data_id`,`group_id`,`tenant_id`,`tag_id`)
  93. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info_tag';
  94. /******************************************/
  95. /* 表名称 = config_tags_relation */
  96. /******************************************/
  97. CREATE TABLE `config_tags_relation` (
  98. `id` bigint(20) NOT NULL COMMENT 'id',
  99. `tag_name` varchar(128) NOT NULL COMMENT 'tag_name',
  100. `tag_type` varchar(64) DEFAULT NULL COMMENT 'tag_type',
  101. `data_id` varchar(255) NOT NULL COMMENT 'data_id',
  102. `group_id` varchar(128) NOT NULL COMMENT 'group_id',
  103. `tenant_id` varchar(128) DEFAULT '' COMMENT 'tenant_id',
  104. `nid` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'nid, 自增长标识',
  105. PRIMARY KEY (`nid`),
  106. UNIQUE KEY `uk_configtagrelation_configidtag` (`id`,`tag_name`,`tag_type`),
  107. KEY `idx_tenant_id` (`tenant_id`)
  108. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_tag_relation';
  109. /******************************************/
  110. /* 表名称 = group_capacity */
  111. /******************************************/
  112. CREATE TABLE `group_capacity` (
  113. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  114. `group_id` varchar(128) NOT NULL DEFAULT '' COMMENT 'Group ID,空字符表示整个集群',
  115. `quota` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '配额,0表示使用默认值',
  116. `usage` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '使用量',
  117. `max_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个配置大小上限,单位为字节,0表示使用默认值',
  118. `max_aggr_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '聚合子配置最大个数,,0表示使用默认值',
  119. `max_aggr_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值',
  120. `max_history_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最大变更历史数量',
  121. `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  122. `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  123. PRIMARY KEY (`id`),
  124. UNIQUE KEY `uk_group_id` (`group_id`)
  125. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='集群、各Group容量信息表';
  126. /******************************************/
  127. /* 表名称 = his_config_info */
  128. /******************************************/
  129. CREATE TABLE `his_config_info` (
  130. `id` bigint(20) unsigned NOT NULL COMMENT 'id',
  131. `nid` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'nid, 自增标识',
  132. `data_id` varchar(255) NOT NULL COMMENT 'data_id',
  133. `group_id` varchar(128) NOT NULL COMMENT 'group_id',
  134. `app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
  135. `content` longtext NOT NULL COMMENT 'content',
  136. `md5` varchar(32) DEFAULT NULL COMMENT 'md5',
  137. `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  138. `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  139. `src_user` text COMMENT 'source user',
  140. `src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip',
  141. `op_type` char(10) DEFAULT NULL COMMENT 'operation type',
  142. `tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
  143. `encrypted_data_key` text NOT NULL COMMENT '密钥',
  144. PRIMARY KEY (`nid`),
  145. KEY `idx_gmt_create` (`gmt_create`),
  146. KEY `idx_gmt_modified` (`gmt_modified`),
  147. KEY `idx_did` (`data_id`)
  148. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='多租户改造';
  149. /******************************************/
  150. /* 表名称 = tenant_capacity */
  151. /******************************************/
  152. CREATE TABLE `tenant_capacity` (
  153. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  154. `tenant_id` varchar(128) NOT NULL DEFAULT '' COMMENT 'Tenant ID',
  155. `quota` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '配额,0表示使用默认值',
  156. `usage` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '使用量',
  157. `max_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个配置大小上限,单位为字节,0表示使用默认值',
  158. `max_aggr_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '聚合子配置最大个数',
  159. `max_aggr_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值',
  160. `max_history_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最大变更历史数量',
  161. `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  162. `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  163. PRIMARY KEY (`id`),
  164. UNIQUE KEY `uk_tenant_id` (`tenant_id`)
  165. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='租户容量信息表';
  166. CREATE TABLE `tenant_info` (
  167. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  168. `kp` varchar(128) NOT NULL COMMENT 'kp',
  169. `tenant_id` varchar(128) default '' COMMENT 'tenant_id',
  170. `tenant_name` varchar(128) default '' COMMENT 'tenant_name',
  171. `tenant_desc` varchar(256) DEFAULT NULL COMMENT 'tenant_desc',
  172. `create_source` varchar(32) DEFAULT NULL COMMENT 'create_source',
  173. `gmt_create` bigint(20) NOT NULL COMMENT '创建时间',
  174. `gmt_modified` bigint(20) NOT NULL COMMENT '修改时间',
  175. PRIMARY KEY (`id`),
  176. UNIQUE KEY `uk_tenant_info_kptenantid` (`kp`,`tenant_id`),
  177. KEY `idx_tenant_id` (`tenant_id`)
  178. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='tenant_info';
  179. CREATE TABLE `users` (
  180. `username` varchar(50) NOT NULL PRIMARY KEY COMMENT 'username',
  181. `password` varchar(500) NOT NULL COMMENT 'password',
  182. `enabled` boolean NOT NULL COMMENT 'enabled'
  183. );
  184. CREATE TABLE `roles` (
  185. `username` varchar(50) NOT NULL COMMENT 'username',
  186. `role` varchar(50) NOT NULL COMMENT 'role',
  187. UNIQUE INDEX `idx_user_role` (`username` ASC, `role` ASC) USING BTREE
  188. );
  189. CREATE TABLE `permissions` (
  190. `role` varchar(50) NOT NULL COMMENT 'role',
  191. `resource` varchar(128) NOT NULL COMMENT 'resource',
  192. `action` varchar(8) NOT NULL COMMENT 'action',
  193. UNIQUE INDEX `uk_role_permission` (`role`,`resource`,`action`) USING BTREE
  194. );
  195. INSERT INTO users (username, password, enabled) VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', TRUE);
  196. INSERT INTO roles (username, role) VALUES ('nacos', 'ROLE_ADMIN');