V1.0.0__initialization.sql 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
  2. /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
  3. /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
  4. /*!40101 SET NAMES utf8 */;
  5. /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
  6. /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
  7. /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
  8. # Create Database
  9. # ------------------------------------------------------------
  10. CREATE DATABASE IF NOT EXISTS ApolloPortalDB DEFAULT CHARACTER SET = utf8mb4;
  11. Use ApolloPortalDB;
  12. # Dump of table app
  13. # ------------------------------------------------------------
  14. DROP TABLE IF EXISTS `App`;
  15. CREATE TABLE `App` (
  16. `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  17. `AppId` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'AppID',
  18. `Name` varchar(500) NOT NULL DEFAULT 'default' COMMENT '应用名',
  19. `OrgId` varchar(32) NOT NULL DEFAULT 'default' COMMENT '部门Id',
  20. `OrgName` varchar(64) NOT NULL DEFAULT 'default' COMMENT '部门名字',
  21. `OwnerName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerName',
  22. `OwnerEmail` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerEmail',
  23. `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  24. `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀',
  25. `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  26. `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT '最后修改人邮箱前缀',
  27. `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
  28. PRIMARY KEY (`Id`),
  29. KEY `AppId` (`AppId`(191)),
  30. KEY `DataChange_LastTime` (`DataChange_LastTime`),
  31. KEY `IX_Name` (`Name`(191))
  32. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='应用表';
  33. # Dump of table appnamespace
  34. # ------------------------------------------------------------
  35. DROP TABLE IF EXISTS `AppNamespace`;
  36. CREATE TABLE `AppNamespace` (
  37. `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增主键',
  38. `Name` varchar(32) NOT NULL DEFAULT '' COMMENT 'namespace名字,注意,需要全局唯一',
  39. `AppId` varchar(32) NOT NULL DEFAULT '' COMMENT 'app id',
  40. `Format` varchar(32) NOT NULL DEFAULT 'properties' COMMENT 'namespace的format类型',
  41. `IsPublic` bit(1) NOT NULL DEFAULT b'0' COMMENT 'namespace是否为公共',
  42. `Comment` varchar(64) NOT NULL DEFAULT '' COMMENT '注释',
  43. `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  44. `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT '' COMMENT '创建人邮箱前缀',
  45. `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  46. `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT '最后修改人邮箱前缀',
  47. `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
  48. PRIMARY KEY (`Id`),
  49. KEY `IX_AppId` (`AppId`),
  50. KEY `Name_AppId` (`Name`,`AppId`),
  51. KEY `DataChange_LastTime` (`DataChange_LastTime`)
  52. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='应用namespace定义';
  53. # Dump of table consumer
  54. # ------------------------------------------------------------
  55. DROP TABLE IF EXISTS `Consumer`;
  56. CREATE TABLE `Consumer` (
  57. `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id',
  58. `AppId` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'AppID',
  59. `Name` varchar(500) NOT NULL DEFAULT 'default' COMMENT '应用名',
  60. `OrgId` varchar(32) NOT NULL DEFAULT 'default' COMMENT '部门Id',
  61. `OrgName` varchar(64) NOT NULL DEFAULT 'default' COMMENT '部门名字',
  62. `OwnerName` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerName',
  63. `OwnerEmail` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'ownerEmail',
  64. `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  65. `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀',
  66. `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  67. `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT '最后修改人邮箱前缀',
  68. `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
  69. PRIMARY KEY (`Id`),
  70. KEY `AppId` (`AppId`(191)),
  71. KEY `DataChange_LastTime` (`DataChange_LastTime`)
  72. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='开放API消费者';
  73. # Dump of table consumeraudit
  74. # ------------------------------------------------------------
  75. DROP TABLE IF EXISTS `ConsumerAudit`;
  76. CREATE TABLE `ConsumerAudit` (
  77. `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id',
  78. `ConsumerId` int(11) unsigned DEFAULT NULL COMMENT 'Consumer Id',
  79. `Uri` varchar(1024) NOT NULL DEFAULT '' COMMENT '访问的Uri',
  80. `Method` varchar(16) NOT NULL DEFAULT '' COMMENT '访问的Method',
  81. `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  82. `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
  83. PRIMARY KEY (`Id`),
  84. KEY `IX_DataChange_LastTime` (`DataChange_LastTime`),
  85. KEY `IX_ConsumerId` (`ConsumerId`)
  86. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='consumer审计表';
  87. # Dump of table consumerrole
  88. # ------------------------------------------------------------
  89. DROP TABLE IF EXISTS `ConsumerRole`;
  90. CREATE TABLE `ConsumerRole` (
  91. `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id',
  92. `ConsumerId` int(11) unsigned DEFAULT NULL COMMENT 'Consumer Id',
  93. `RoleId` int(10) unsigned DEFAULT NULL COMMENT 'Role Id',
  94. `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  95. `DataChange_CreatedBy` varchar(32) DEFAULT '' COMMENT '创建人邮箱前缀',
  96. `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  97. `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT '最后修改人邮箱前缀',
  98. `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
  99. PRIMARY KEY (`Id`),
  100. KEY `IX_DataChange_LastTime` (`DataChange_LastTime`),
  101. KEY `IX_RoleId` (`RoleId`),
  102. KEY `IX_ConsumerId_RoleId` (`ConsumerId`,`RoleId`)
  103. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='consumer和role的绑定表';
  104. # Dump of table consumertoken
  105. # ------------------------------------------------------------
  106. DROP TABLE IF EXISTS `ConsumerToken`;
  107. CREATE TABLE `ConsumerToken` (
  108. `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id',
  109. `ConsumerId` int(11) unsigned DEFAULT NULL COMMENT 'ConsumerId',
  110. `Token` varchar(128) NOT NULL DEFAULT '' COMMENT 'token',
  111. `Expires` datetime NOT NULL DEFAULT '2099-01-01 00:00:00' COMMENT 'token失效时间',
  112. `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  113. `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀',
  114. `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  115. `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT '最后修改人邮箱前缀',
  116. `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
  117. PRIMARY KEY (`Id`),
  118. UNIQUE KEY `IX_Token` (`Token`),
  119. KEY `DataChange_LastTime` (`DataChange_LastTime`)
  120. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='consumer token表';
  121. # Dump of table favorite
  122. # ------------------------------------------------------------
  123. DROP TABLE IF EXISTS `Favorite`;
  124. CREATE TABLE `Favorite` (
  125. `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键',
  126. `UserId` varchar(32) NOT NULL DEFAULT 'default' COMMENT '收藏的用户',
  127. `AppId` varchar(500) NOT NULL DEFAULT 'default' COMMENT 'AppID',
  128. `Position` int(32) NOT NULL DEFAULT '10000' COMMENT '收藏顺序',
  129. `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  130. `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀',
  131. `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  132. `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT '最后修改人邮箱前缀',
  133. `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
  134. PRIMARY KEY (`Id`),
  135. KEY `AppId` (`AppId`(191)),
  136. KEY `IX_UserId` (`UserId`),
  137. KEY `DataChange_LastTime` (`DataChange_LastTime`)
  138. ) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8mb4 COMMENT='应用收藏表';
  139. # Dump of table permission
  140. # ------------------------------------------------------------
  141. DROP TABLE IF EXISTS `Permission`;
  142. CREATE TABLE `Permission` (
  143. `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id',
  144. `PermissionType` varchar(32) NOT NULL DEFAULT '' COMMENT '权限类型',
  145. `TargetId` varchar(256) NOT NULL DEFAULT '' COMMENT '权限对象类型',
  146. `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  147. `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT '' COMMENT '创建人邮箱前缀',
  148. `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  149. `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT '最后修改人邮箱前缀',
  150. `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
  151. PRIMARY KEY (`Id`),
  152. KEY `IX_TargetId_PermissionType` (`TargetId`(191),`PermissionType`),
  153. KEY `IX_DataChange_LastTime` (`DataChange_LastTime`)
  154. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='permission表';
  155. # Dump of table role
  156. # ------------------------------------------------------------
  157. DROP TABLE IF EXISTS `Role`;
  158. CREATE TABLE `Role` (
  159. `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id',
  160. `RoleName` varchar(256) NOT NULL DEFAULT '' COMMENT 'Role name',
  161. `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  162. `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀',
  163. `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  164. `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT '最后修改人邮箱前缀',
  165. `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
  166. PRIMARY KEY (`Id`),
  167. KEY `IX_RoleName` (`RoleName`(191)),
  168. KEY `IX_DataChange_LastTime` (`DataChange_LastTime`)
  169. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色表';
  170. # Dump of table rolepermission
  171. # ------------------------------------------------------------
  172. DROP TABLE IF EXISTS `RolePermission`;
  173. CREATE TABLE `RolePermission` (
  174. `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id',
  175. `RoleId` int(10) unsigned DEFAULT NULL COMMENT 'Role Id',
  176. `PermissionId` int(10) unsigned DEFAULT NULL COMMENT 'Permission Id',
  177. `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  178. `DataChange_CreatedBy` varchar(32) DEFAULT '' COMMENT '创建人邮箱前缀',
  179. `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  180. `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT '最后修改人邮箱前缀',
  181. `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
  182. PRIMARY KEY (`Id`),
  183. KEY `IX_DataChange_LastTime` (`DataChange_LastTime`),
  184. KEY `IX_RoleId` (`RoleId`),
  185. KEY `IX_PermissionId` (`PermissionId`)
  186. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='角色和权限的绑定表';
  187. # Dump of table serverconfig
  188. # ------------------------------------------------------------
  189. DROP TABLE IF EXISTS `ServerConfig`;
  190. CREATE TABLE `ServerConfig` (
  191. `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id',
  192. `Key` varchar(64) NOT NULL DEFAULT 'default' COMMENT '配置项Key',
  193. `Value` varchar(2048) NOT NULL DEFAULT 'default' COMMENT '配置项值',
  194. `Comment` varchar(1024) DEFAULT '' COMMENT '注释',
  195. `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  196. `DataChange_CreatedBy` varchar(32) NOT NULL DEFAULT 'default' COMMENT '创建人邮箱前缀',
  197. `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  198. `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT '最后修改人邮箱前缀',
  199. `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
  200. PRIMARY KEY (`Id`),
  201. KEY `IX_Key` (`Key`),
  202. KEY `DataChange_LastTime` (`DataChange_LastTime`)
  203. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='配置服务自身配置';
  204. # Dump of table userrole
  205. # ------------------------------------------------------------
  206. DROP TABLE IF EXISTS `UserRole`;
  207. CREATE TABLE `UserRole` (
  208. `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id',
  209. `UserId` varchar(128) DEFAULT '' COMMENT '用户身份标识',
  210. `RoleId` int(10) unsigned DEFAULT NULL COMMENT 'Role Id',
  211. `IsDeleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '1: deleted, 0: normal',
  212. `DataChange_CreatedBy` varchar(32) DEFAULT '' COMMENT '创建人邮箱前缀',
  213. `DataChange_CreatedTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  214. `DataChange_LastModifiedBy` varchar(32) DEFAULT '' COMMENT '最后修改人邮箱前缀',
  215. `DataChange_LastTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
  216. PRIMARY KEY (`Id`),
  217. KEY `IX_DataChange_LastTime` (`DataChange_LastTime`),
  218. KEY `IX_RoleId` (`RoleId`),
  219. KEY `IX_UserId_RoleId` (`UserId`,`RoleId`)
  220. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户和role的绑定表';
  221. # Dump of table Users
  222. # ------------------------------------------------------------
  223. DROP TABLE IF EXISTS `Users`;
  224. CREATE TABLE `Users` (
  225. `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id',
  226. `Username` varchar(64) NOT NULL DEFAULT 'default' COMMENT '用户名',
  227. `Password` varchar(64) NOT NULL DEFAULT 'default' COMMENT '密码',
  228. `Email` varchar(64) NOT NULL DEFAULT 'default' COMMENT '邮箱地址',
  229. `Enabled` tinyint(4) DEFAULT NULL COMMENT '是否有效',
  230. PRIMARY KEY (`Id`)
  231. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户表';
  232. # Dump of table Authorities
  233. # ------------------------------------------------------------
  234. DROP TABLE IF EXISTS `Authorities`;
  235. CREATE TABLE `Authorities` (
  236. `Id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增Id',
  237. `Username` varchar(64) NOT NULL,
  238. `Authority` varchar(50) NOT NULL,
  239. PRIMARY KEY (`Id`)
  240. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  241. # Config
  242. # ------------------------------------------------------------
  243. INSERT INTO `ServerConfig` (`Key`, `Value`, `Comment`)
  244. VALUES
  245. ('apollo.portal.envs', 'dev', '可支持的环境列表'),
  246. ('organizations', '[{\"orgId\":\"TEST1\",\"orgName\":\"样例部门1\"},{\"orgId\":\"TEST2\",\"orgName\":\"样例部门2\"}]', '部门列表'),
  247. ('superAdmin', 'apollo', 'Portal超级管理员'),
  248. ('api.readTimeout', '10000', 'http接口read timeout'),
  249. ('consumer.token.salt', 'someSalt', 'consumer token salt'),
  250. ('admin.createPrivateNamespace.switch', 'true', '是否允许项目管理员创建私有namespace'),
  251. ('configView.memberOnly.envs', 'pro', '只对项目成员显示配置信息的环境列表,多个env以英文逗号分隔');
  252. INSERT INTO `Users` (`Username`, `Password`, `Email`, `Enabled`)
  253. VALUES
  254. ('apollo', '$2a$10$7r20uS.BQ9uBpf3Baj3uQOZvMVvB1RN3PYoKE94gtz2.WAOuiiwXS', 'apollo@acme.com', 1);
  255. INSERT INTO `Authorities` (`Username`, `Authority`) VALUES ('apollo', 'ROLE_user');
  256. /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
  257. /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
  258. /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
  259. /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
  260. /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
  261. /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;