nacos-mysql.sql 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. /* 数据库全名 = nacos_config */
  18. /* 表名称 = config_info */
  19. /******************************************/
  20. CREATE TABLE `config_info` (
  21. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  22. `data_id` varchar(255) NOT NULL COMMENT 'data_id',
  23. `group_id` varchar(128) DEFAULT NULL,
  24. `content` longtext NOT NULL COMMENT 'content',
  25. `md5` varchar(32) DEFAULT NULL COMMENT 'md5',
  26. `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  27. `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  28. `src_user` text COMMENT 'source user',
  29. `src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip',
  30. `app_name` varchar(128) DEFAULT NULL,
  31. `tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
  32. `c_desc` varchar(256) DEFAULT NULL,
  33. `c_use` varchar(64) DEFAULT NULL,
  34. `effect` varchar(64) DEFAULT NULL,
  35. `type` varchar(64) DEFAULT NULL,
  36. `c_schema` text,
  37. `encrypted_data_key` text NOT NULL COMMENT '秘钥',
  38. PRIMARY KEY (`id`),
  39. UNIQUE KEY `uk_configinfo_datagrouptenant` (`data_id`,`group_id`,`tenant_id`)
  40. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info';
  41. /******************************************/
  42. /* 数据库全名 = nacos_config */
  43. /* 表名称 = config_info_aggr */
  44. /******************************************/
  45. CREATE TABLE `config_info_aggr` (
  46. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  47. `data_id` varchar(255) NOT NULL COMMENT 'data_id',
  48. `group_id` varchar(128) NOT NULL COMMENT 'group_id',
  49. `datum_id` varchar(255) NOT NULL COMMENT 'datum_id',
  50. `content` longtext NOT NULL COMMENT '内容',
  51. `gmt_modified` datetime NOT NULL COMMENT '修改时间',
  52. `app_name` varchar(128) DEFAULT NULL,
  53. `tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
  54. PRIMARY KEY (`id`),
  55. UNIQUE KEY `uk_configinfoaggr_datagrouptenantdatum` (`data_id`,`group_id`,`tenant_id`,`datum_id`)
  56. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='增加租户字段';
  57. /******************************************/
  58. /* 数据库全名 = nacos_config */
  59. /* 表名称 = config_info_beta */
  60. /******************************************/
  61. CREATE TABLE `config_info_beta` (
  62. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  63. `data_id` varchar(255) NOT NULL COMMENT 'data_id',
  64. `group_id` varchar(128) NOT NULL COMMENT 'group_id',
  65. `app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
  66. `content` longtext NOT NULL COMMENT 'content',
  67. `beta_ips` varchar(1024) DEFAULT NULL COMMENT 'betaIps',
  68. `md5` varchar(32) DEFAULT NULL COMMENT 'md5',
  69. `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  70. `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  71. `src_user` text COMMENT 'source user',
  72. `src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip',
  73. `tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
  74. `encrypted_data_key` text NOT NULL COMMENT '秘钥',
  75. PRIMARY KEY (`id`),
  76. UNIQUE KEY `uk_configinfobeta_datagrouptenant` (`data_id`,`group_id`,`tenant_id`)
  77. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info_beta';
  78. /******************************************/
  79. /* 数据库全名 = nacos_config */
  80. /* 表名称 = config_info_tag */
  81. /******************************************/
  82. CREATE TABLE `config_info_tag` (
  83. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  84. `data_id` varchar(255) NOT NULL COMMENT 'data_id',
  85. `group_id` varchar(128) NOT NULL COMMENT 'group_id',
  86. `tenant_id` varchar(128) DEFAULT '' COMMENT 'tenant_id',
  87. `tag_id` varchar(128) NOT NULL COMMENT 'tag_id',
  88. `app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
  89. `content` longtext NOT NULL COMMENT 'content',
  90. `md5` varchar(32) DEFAULT NULL COMMENT 'md5',
  91. `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  92. `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  93. `src_user` text COMMENT 'source user',
  94. `src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip',
  95. PRIMARY KEY (`id`),
  96. UNIQUE KEY `uk_configinfotag_datagrouptenanttag` (`data_id`,`group_id`,`tenant_id`,`tag_id`)
  97. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info_tag';
  98. /******************************************/
  99. /* 数据库全名 = nacos_config */
  100. /* 表名称 = config_tags_relation */
  101. /******************************************/
  102. CREATE TABLE `config_tags_relation` (
  103. `id` bigint(20) NOT NULL COMMENT 'id',
  104. `tag_name` varchar(128) NOT NULL COMMENT 'tag_name',
  105. `tag_type` varchar(64) DEFAULT NULL COMMENT 'tag_type',
  106. `data_id` varchar(255) NOT NULL COMMENT 'data_id',
  107. `group_id` varchar(128) NOT NULL COMMENT 'group_id',
  108. `tenant_id` varchar(128) DEFAULT '' COMMENT 'tenant_id',
  109. `nid` bigint(20) NOT NULL AUTO_INCREMENT,
  110. PRIMARY KEY (`nid`),
  111. UNIQUE KEY `uk_configtagrelation_configidtag` (`id`,`tag_name`,`tag_type`),
  112. KEY `idx_tenant_id` (`tenant_id`)
  113. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_tag_relation';
  114. /******************************************/
  115. /* 数据库全名 = nacos_config */
  116. /* 表名称 = group_capacity */
  117. /******************************************/
  118. CREATE TABLE `group_capacity` (
  119. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  120. `group_id` varchar(128) NOT NULL DEFAULT '' COMMENT 'Group ID,空字符表示整个集群',
  121. `quota` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '配额,0表示使用默认值',
  122. `usage` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '使用量',
  123. `max_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个配置大小上限,单位为字节,0表示使用默认值',
  124. `max_aggr_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '聚合子配置最大个数,,0表示使用默认值',
  125. `max_aggr_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值',
  126. `max_history_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最大变更历史数量',
  127. `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  128. `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  129. PRIMARY KEY (`id`),
  130. UNIQUE KEY `uk_group_id` (`group_id`)
  131. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='集群、各Group容量信息表';
  132. /******************************************/
  133. /* 数据库全名 = nacos_config */
  134. /* 表名称 = his_config_info */
  135. /******************************************/
  136. CREATE TABLE `his_config_info` (
  137. `id` bigint(20) unsigned NOT NULL,
  138. `nid` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  139. `data_id` varchar(255) NOT NULL,
  140. `group_id` varchar(128) NOT NULL,
  141. `app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
  142. `content` longtext NOT NULL,
  143. `md5` varchar(32) DEFAULT NULL,
  144. `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  145. `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  146. `src_user` text,
  147. `src_ip` varchar(50) DEFAULT NULL,
  148. `op_type` char(10) DEFAULT NULL,
  149. `tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
  150. `encrypted_data_key` text NOT NULL COMMENT '秘钥',
  151. PRIMARY KEY (`nid`),
  152. KEY `idx_gmt_create` (`gmt_create`),
  153. KEY `idx_gmt_modified` (`gmt_modified`),
  154. KEY `idx_did` (`data_id`)
  155. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='多租户改造';
  156. /******************************************/
  157. /* 数据库全名 = nacos_config */
  158. /* 表名称 = tenant_capacity */
  159. /******************************************/
  160. CREATE TABLE `tenant_capacity` (
  161. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  162. `tenant_id` varchar(128) NOT NULL DEFAULT '' COMMENT 'Tenant ID',
  163. `quota` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '配额,0表示使用默认值',
  164. `usage` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '使用量',
  165. `max_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个配置大小上限,单位为字节,0表示使用默认值',
  166. `max_aggr_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '聚合子配置最大个数',
  167. `max_aggr_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值',
  168. `max_history_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最大变更历史数量',
  169. `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  170. `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  171. PRIMARY KEY (`id`),
  172. UNIQUE KEY `uk_tenant_id` (`tenant_id`)
  173. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='租户容量信息表';
  174. CREATE TABLE `tenant_info` (
  175. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  176. `kp` varchar(128) NOT NULL COMMENT 'kp',
  177. `tenant_id` varchar(128) default '' COMMENT 'tenant_id',
  178. `tenant_name` varchar(128) default '' COMMENT 'tenant_name',
  179. `tenant_desc` varchar(256) DEFAULT NULL COMMENT 'tenant_desc',
  180. `create_source` varchar(32) DEFAULT NULL COMMENT 'create_source',
  181. `gmt_create` bigint(20) NOT NULL COMMENT '创建时间',
  182. `gmt_modified` bigint(20) NOT NULL COMMENT '修改时间',
  183. PRIMARY KEY (`id`),
  184. UNIQUE KEY `uk_tenant_info_kptenantid` (`kp`,`tenant_id`),
  185. KEY `idx_tenant_id` (`tenant_id`)
  186. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='tenant_info';
  187. CREATE TABLE `users` (
  188. `username` varchar(50) NOT NULL PRIMARY KEY,
  189. `password` varchar(500) NOT NULL,
  190. `enabled` boolean NOT NULL
  191. );
  192. CREATE TABLE `roles` (
  193. `username` varchar(50) NOT NULL,
  194. `role` varchar(50) NOT NULL,
  195. UNIQUE INDEX `idx_user_role` (`username` ASC, `role` ASC) USING BTREE
  196. );
  197. CREATE TABLE `permissions` (
  198. `role` varchar(50) NOT NULL,
  199. `resource` varchar(255) NOT NULL,
  200. `action` varchar(8) NOT NULL,
  201. UNIQUE INDEX `uk_role_permission` (`role`,`resource`,`action`) USING BTREE
  202. );
  203. INSERT INTO users (username, password, enabled) VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', TRUE);
  204. INSERT INTO roles (username, role) VALUES ('nacos', 'ROLE_ADMIN');