derby-schema.sql 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. CREATE SCHEMA nacos AUTHORIZATION nacos;
  17. CREATE TABLE config_info (
  18. id bigint NOT NULL generated by default as identity,
  19. data_id varchar(255) NOT NULL,
  20. group_id varchar(128) NOT NULL,
  21. tenant_id varchar(128) default '',
  22. app_name varchar(128),
  23. content CLOB,
  24. md5 varchar(32) DEFAULT NULL,
  25. gmt_create timestamp NOT NULL DEFAULT '2010-05-05 00:00:00',
  26. gmt_modified timestamp NOT NULL DEFAULT '2010-05-05 00:00:00',
  27. src_user varchar(128) DEFAULT NULL,
  28. src_ip varchar(50) DEFAULT NULL,
  29. c_desc varchar(256) DEFAULT NULL,
  30. c_use varchar(64) DEFAULT NULL,
  31. effect varchar(64) DEFAULT NULL,
  32. type varchar(64) DEFAULT NULL,
  33. c_schema LONG VARCHAR DEFAULT NULL,
  34. encrypted_data_key LONG VARCHAR DEFAULT NULL,
  35. constraint configinfo_id_key PRIMARY KEY (id),
  36. constraint uk_configinfo_datagrouptenant UNIQUE (data_id,group_id,tenant_id));
  37. CREATE INDEX configinfo_dataid_key_idx ON config_info(data_id);
  38. CREATE INDEX configinfo_groupid_key_idx ON config_info(group_id);
  39. CREATE INDEX configinfo_dataid_group_key_idx ON config_info(data_id, group_id);
  40. CREATE TABLE his_config_info (
  41. id bigint NOT NULL,
  42. nid bigint NOT NULL generated by default as identity,
  43. data_id varchar(255) NOT NULL,
  44. group_id varchar(128) NOT NULL,
  45. tenant_id varchar(128) default '',
  46. app_name varchar(128),
  47. content CLOB,
  48. md5 varchar(32) DEFAULT NULL,
  49. gmt_create timestamp NOT NULL DEFAULT '2010-05-05 00:00:00.000',
  50. gmt_modified timestamp NOT NULL DEFAULT '2010-05-05 00:00:00.000',
  51. src_user varchar(128),
  52. src_ip varchar(50) DEFAULT NULL,
  53. publish_type varchar(50) DEFAULT 'formal',
  54. gray_name varchar(128) DEFAULT NULL,
  55. ext_info CLOB,
  56. op_type char(10) DEFAULT NULL,
  57. encrypted_data_key LONG VARCHAR DEFAULT NULL,
  58. constraint hisconfiginfo_nid_key PRIMARY KEY (nid));
  59. CREATE INDEX hisconfiginfo_dataid_key_idx ON his_config_info(data_id);
  60. CREATE INDEX hisconfiginfo_gmt_create_idx ON his_config_info(gmt_create);
  61. CREATE INDEX hisconfiginfo_gmt_modified_idx ON his_config_info(gmt_modified);
  62. CREATE TABLE config_info_beta (
  63. id bigint NOT NULL generated by default as identity,
  64. data_id varchar(255) NOT NULL,
  65. group_id varchar(128) NOT NULL,
  66. tenant_id varchar(128) default '',
  67. app_name varchar(128),
  68. content CLOB,
  69. beta_ips varchar(1024),
  70. md5 varchar(32) DEFAULT NULL,
  71. gmt_create timestamp NOT NULL DEFAULT '2010-05-05 00:00:00',
  72. gmt_modified timestamp NOT NULL DEFAULT '2010-05-05 00:00:00',
  73. src_user varchar(128),
  74. src_ip varchar(50) DEFAULT NULL,
  75. encrypted_data_key LONG VARCHAR DEFAULT NULL,
  76. constraint configinfobeta_id_key PRIMARY KEY (id),
  77. constraint uk_configinfobeta_datagrouptenant UNIQUE (data_id,group_id,tenant_id));
  78. CREATE TABLE config_info_tag (
  79. id bigint NOT NULL generated by default as identity,
  80. data_id varchar(255) NOT NULL,
  81. group_id varchar(128) NOT NULL,
  82. tenant_id varchar(128) default '',
  83. tag_id varchar(128) NOT NULL,
  84. app_name varchar(128),
  85. content CLOB,
  86. md5 varchar(32) DEFAULT NULL,
  87. gmt_create timestamp NOT NULL DEFAULT '2010-05-05 00:00:00',
  88. gmt_modified timestamp NOT NULL DEFAULT '2010-05-05 00:00:00',
  89. src_user varchar(128),
  90. src_ip varchar(50) DEFAULT NULL,
  91. constraint configinfotag_id_key PRIMARY KEY (id),
  92. constraint uk_configinfotag_datagrouptenanttag UNIQUE (data_id,group_id,tenant_id,tag_id));
  93. CREATE TABLE config_info_gray (
  94. id bigint NOT NULL generated by default as identity,
  95. data_id varchar(255) NOT NULL,
  96. group_id varchar(128) NOT NULL,
  97. tenant_id varchar(128) default '',
  98. gray_name varchar(128) NOT NULL,
  99. gray_rule CLOB,
  100. app_name varchar(128),
  101. src_ip varchar(128),
  102. src_user varchar(128) default '',
  103. content CLOB,
  104. md5 varchar(32) DEFAULT NULL,
  105. encrypted_data_key varchar(32) DEFAULT NULL,
  106. gmt_create timestamp NOT NULL DEFAULT '2010-05-05 00:00:00',
  107. gmt_modified timestamp NOT NULL DEFAULT '2010-05-05 00:00:00',
  108. constraint configinfogray_id_key PRIMARY KEY (id),
  109. constraint uk_configinfogray_datagrouptenantgrayname UNIQUE (data_id,group_id,tenant_id,gray_name));
  110. CREATE INDEX config_info_gray_dataid_gmt_modified ON config_info_gray(data_id,gmt_modified);
  111. CREATE INDEX config_info_gray_gmt_modified ON config_info_gray(gmt_modified);
  112. CREATE TABLE app_list (
  113. id bigint NOT NULL generated by default as identity,
  114. app_name varchar(128) NOT NULL,
  115. is_dynamic_collect_disabled smallint DEFAULT 0,
  116. last_sub_info_collected_time timestamp DEFAULT '1970-01-01 08:00:00.0',
  117. sub_info_lock_owner varchar(128),
  118. sub_info_lock_time timestamp DEFAULT '1970-01-01 08:00:00.0',
  119. constraint applist_id_key PRIMARY KEY (id),
  120. constraint uk_appname UNIQUE (app_name));
  121. CREATE TABLE app_configdata_relation_subs (
  122. id bigint NOT NULL generated by default as identity,
  123. app_name varchar(128) NOT NULL,
  124. data_id varchar(255) NOT NULL,
  125. group_id varchar(128) NOT NULL,
  126. gmt_modified timestamp DEFAULT '2010-05-05 00:00:00',
  127. constraint configdatarelationsubs_id_key PRIMARY KEY (id),
  128. constraint uk_app_sub_config_datagroup UNIQUE (app_name, data_id, group_id));
  129. CREATE TABLE app_configdata_relation_pubs (
  130. id bigint NOT NULL generated by default as identity,
  131. app_name varchar(128) NOT NULL,
  132. data_id varchar(255) NOT NULL,
  133. group_id varchar(128) NOT NULL,
  134. gmt_modified timestamp DEFAULT '2010-05-05 00:00:00',
  135. constraint configdatarelationpubs_id_key PRIMARY KEY (id),
  136. constraint uk_app_pub_config_datagroup UNIQUE (app_name, data_id, group_id));
  137. CREATE TABLE config_tags_relation (
  138. id bigint NOT NULL,
  139. tag_name varchar(128) NOT NULL,
  140. tag_type varchar(64) DEFAULT NULL,
  141. data_id varchar(255) NOT NULL,
  142. group_id varchar(128) NOT NULL,
  143. tenant_id varchar(128) DEFAULT '',
  144. nid bigint NOT NULL generated by default as identity,
  145. constraint config_tags_id_key PRIMARY KEY (nid),
  146. constraint uk_configtagrelation_configidtag UNIQUE (id, tag_name, tag_type));
  147. CREATE INDEX config_tags_tenant_id_idx ON config_tags_relation(tenant_id);
  148. CREATE TABLE group_capacity (
  149. id bigint NOT NULL generated by default as identity,
  150. group_id varchar(128) DEFAULT '',
  151. quota int DEFAULT 0,
  152. usage int DEFAULT 0,
  153. max_size int DEFAULT 0,
  154. max_aggr_count int DEFAULT 0,
  155. max_aggr_size int DEFAULT 0,
  156. max_history_count int DEFAULT 0,
  157. gmt_create timestamp DEFAULT '2010-05-05 00:00:00',
  158. gmt_modified timestamp DEFAULT '2010-05-05 00:00:00',
  159. constraint group_capacity_id_key PRIMARY KEY (id),
  160. constraint uk_group_id UNIQUE (group_id));
  161. CREATE TABLE tenant_capacity (
  162. id bigint NOT NULL generated by default as identity,
  163. tenant_id varchar(128) DEFAULT '',
  164. quota int DEFAULT 0,
  165. usage int DEFAULT 0,
  166. max_size int DEFAULT 0,
  167. max_aggr_count int DEFAULT 0,
  168. max_aggr_size int DEFAULT 0,
  169. max_history_count int DEFAULT 0,
  170. gmt_create timestamp DEFAULT '2010-05-05 00:00:00',
  171. gmt_modified timestamp DEFAULT '2010-05-05 00:00:00',
  172. constraint tenant_capacity_id_key PRIMARY KEY (id),
  173. constraint uk_tenant_id UNIQUE (tenant_id));
  174. CREATE TABLE tenant_info (
  175. id bigint NOT NULL generated by default as identity,
  176. kp varchar(128) NOT NULL,
  177. tenant_id varchar(128) DEFAULT '',
  178. tenant_name varchar(128) DEFAULT '',
  179. tenant_desc varchar(256) DEFAULT NULL,
  180. create_source varchar(32) DEFAULT NULL,
  181. gmt_create bigint NOT NULL,
  182. gmt_modified bigint NOT NULL,
  183. constraint tenant_info_id_key PRIMARY KEY (id),
  184. constraint uk_tenant_info_kptenantid UNIQUE (kp,tenant_id));
  185. CREATE INDEX tenant_info_tenant_id_idx ON tenant_info(tenant_id);
  186. CREATE TABLE users (
  187. username varchar(50) NOT NULL PRIMARY KEY,
  188. password varchar(500) NOT NULL,
  189. enabled boolean NOT NULL DEFAULT true
  190. );
  191. CREATE TABLE roles (
  192. username varchar(50) NOT NULL,
  193. role varchar(50) NOT NULL,
  194. constraint uk_username_role UNIQUE (username,role)
  195. );
  196. CREATE TABLE permissions (
  197. role varchar(50) NOT NULL,
  198. resource varchar(512) NOT NULL,
  199. action varchar(8) NOT NULL,
  200. constraint uk_role_permission UNIQUE (role,resource,action)
  201. );
  202. /******************************************/
  203. /* ipv6 support */
  204. /******************************************/
  205. ALTER TABLE config_info_tag ADD src_ip varchar(50) DEFAULT NULL;
  206. ALTER TABLE his_config_info ADD src_ip varchar(50) DEFAULT NULL ;
  207. ALTER TABLE config_info ADD src_ip varchar(50) DEFAULT NULL ;
  208. ALTER TABLE config_info_beta ADD src_ip varchar(50) DEFAULT NULL ;
  209. ALTER TABLE his_config_info ADD publish_type varchar(50) DEFAULT 'formal';
  210. ALTER TABLE his_config_info ADD ext_info CLOB DEFAULT NULL ;
  211. ALTER TABLE his_config_info ADD gray_name varchar(128) DEFAULT NULL;