-
Notifications
You must be signed in to change notification settings - Fork 3
/
nacos-2.1.0-postgresql.sql
275 lines (221 loc) · 11.1 KB
/
nacos-2.1.0-postgresql.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
create table if not exists public.config_info
(
id bigserial
primary key,
data_id varchar(255) not null,
group_id varchar(255) default NULL::character varying,
content text not null,
md5 varchar(32) default NULL::character varying,
gmt_create timestamp default CURRENT_TIMESTAMP not null,
gmt_modified timestamp default CURRENT_TIMESTAMP not null,
src_user text,
src_ip varchar(50) default NULL::character varying,
app_name varchar(128) default NULL::character varying,
tenant_id varchar(128) default ''::character varying,
c_desc varchar(256) default NULL::character varying,
c_use varchar(64) default NULL::character varying,
effect varchar(64) default NULL::character varying,
type varchar(64) default NULL::character varying,
c_schema text,
encrypted_data_key text,
constraint uk_configinfo_datagrouptenant
unique (data_id, group_id, tenant_id)
);
create table if not exists public.config_info_aggr
(
id bigserial
primary key,
data_id varchar(255) not null,
group_id varchar(255) not null,
datum_id varchar(255) not null,
content text not null,
gmt_modified timestamp default CURRENT_TIMESTAMP not null,
app_name varchar(128) default NULL::character varying,
tenant_id varchar(128) default ''::character varying,
constraint uk_configinfoaggr_datagrouptenantdatum
unique (data_id, group_id, tenant_id, datum_id)
);
comment on table public.config_info_aggr is '增加租户字段';
comment on column public.config_info_aggr.content is '内容';
comment on column public.config_info_aggr.gmt_modified is '修改时间';
comment on column public.config_info_aggr.tenant_id is '租户字段';
create table if not exists public.config_info_beta
(
id bigserial
primary key,
data_id varchar(255) not null,
group_id varchar(128) not null,
app_name varchar(128) default NULL::character varying,
content text not null,
beta_ips varchar(1024) default NULL::character varying,
md5 varchar(32) default NULL::character varying,
gmt_create timestamp default CURRENT_TIMESTAMP not null,
gmt_modified timestamp default CURRENT_TIMESTAMP not null,
src_user text,
src_ip varchar(50) default NULL::character varying,
tenant_id varchar(128) default ''::character varying,
encrypted_data_key text,
constraint uk_configinfobeta_datagrouptenant
unique (data_id, group_id, tenant_id)
);
comment on column public.config_info_beta.gmt_create is '创建时间';
comment on column public.config_info_beta.gmt_modified is '修改时间';
comment on column public.config_info_beta.tenant_id is '租户字段';
create table if not exists public.config_info_tag
(
id bigserial
primary key,
data_id varchar(255) not null,
group_id varchar(128) not null,
tenant_id varchar(128) default ''::character varying,
tag_id varchar(128) not null,
app_name varchar(128) default NULL::character varying,
content text not null,
md5 varchar(32) default NULL::character varying,
gmt_create timestamp default CURRENT_TIMESTAMP not null,
gmt_modified timestamp default CURRENT_TIMESTAMP not null,
src_user text,
src_ip varchar(50) default NULL::character varying,
constraint uk_configinfotag_datagrouptenanttag
unique (data_id, group_id, tenant_id, tag_id)
);
comment on column public.config_info_tag.tenant_id is '租户字段';
comment on column public.config_info_tag.gmt_create is '创建时间';
comment on column public.config_info_tag.gmt_modified is '修改时间';
create table if not exists public.config_tags_relation
(
id bigint not null,
tag_name varchar(128) not null,
tag_type varchar(64) default NULL::character varying,
data_id varchar(255) not null,
group_id varchar(128) not null,
tenant_id varchar(128) default ''::character varying,
nid bigserial
primary key,
constraint uk_configtagrelation_configidtag
unique (id, tag_name, tag_type)
);
create index if not exists idx_tenant_id
on public.config_tags_relation (tenant_id);
create table if not exists public.group_capacity
(
id bigserial
primary key,
group_id varchar(128) default ''::character varying not null
constraint uk_group_id
unique,
quota integer default 0 not null,
usage integer default 0 not null,
max_size integer default 0 not null,
max_aggr_count integer default 0 not null,
max_aggr_size integer default 0 not null,
max_history_count integer default 0 not null,
gmt_create timestamp default CURRENT_TIMESTAMP not null,
gmt_modified timestamp default CURRENT_TIMESTAMP not null
);
comment on table public.group_capacity is '集群、各Group容量信息表';
comment on column public.group_capacity.id is '主键id';
comment on column public.group_capacity.group_id is 'Group ID,空字符表示整个集群';
comment on column public.group_capacity.quota is '配额,0表示使用默认值';
comment on column public.group_capacity.usage is '使用量';
comment on column public.group_capacity.max_size is '单个配置大小上限,单位为字节,0表示使用默认值';
comment on column public.group_capacity.max_aggr_count is '聚合子配置最大个数,,0表示使用默认值';
comment on column public.group_capacity.max_aggr_size is '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值';
comment on column public.group_capacity.max_history_count is '最大变更历史数量';
comment on column public.group_capacity.gmt_create is '创建时间';
comment on column public.group_capacity.gmt_modified is '修改时间';
create table if not exists public.his_config_info
(
id bigint not null,
nid bigserial
primary key,
data_id varchar(255) not null,
group_id varchar(128) not null,
app_name varchar(128) default NULL::character varying,
content text not null,
md5 varchar(32) default NULL::character varying,
gmt_create timestamp default CURRENT_TIMESTAMP not null,
gmt_modified timestamp default CURRENT_TIMESTAMP not null,
src_user text,
src_ip varchar(50) default NULL::character varying,
op_type char(10) default NULL::bpchar,
tenant_id varchar(128) default ''::character varying,
encrypted_data_key text
);
create index if not exists idx_gmt_create
on public.his_config_info (gmt_create);
create index if not exists idx_gmt_modified
on public.his_config_info (gmt_modified);
create index if not exists idx_did
on public.his_config_info (data_id);
create table if not exists public.tenant_capacity
(
id bigserial
primary key,
tenant_id varchar(128) default ''::character varying not null
constraint uk_tenant_id
unique,
quota integer default 0 not null,
usage integer default 0 not null,
max_size integer default 0 not null,
max_aggr_count integer default 0 not null,
max_aggr_size integer default 0 not null,
max_history_count integer default 0 not null,
gmt_create timestamp default CURRENT_TIMESTAMP not null,
gmt_modified timestamp default CURRENT_TIMESTAMP not null
);
comment on table public.tenant_capacity is '租户容量信息表';
comment on column public.tenant_capacity.id is '主键id';
comment on column public.tenant_capacity.quota is '配额,0表示使用默认值';
comment on column public.tenant_capacity.usage is '使用量';
comment on column public.tenant_capacity.max_size is '单个配置大小上限,单位为字节,0表示使用默认值';
comment on column public.tenant_capacity.max_aggr_count is '聚合子配置最大个数,,0表示使用默认值';
comment on column public.tenant_capacity.max_aggr_size is '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值';
comment on column public.tenant_capacity.max_history_count is '最大变更历史数量';
comment on column public.tenant_capacity.gmt_create is '创建时间';
comment on column public.tenant_capacity.gmt_modified is '修改时间';
create table if not exists public.tenant_info
(
id bigserial
primary key,
kp varchar(128) not null,
tenant_id varchar(128) default ''::character varying,
tenant_name varchar(128) default ''::character varying,
tenant_desc varchar(256) default NULL::character varying,
create_source varchar(32) default NULL::character varying,
gmt_create bigint not null,
gmt_modified bigint not null,
constraint uk_tenant_info_kptenantid
unique (kp, tenant_id)
);
comment on column public.tenant_info.id is '主键id';
comment on column public.tenant_info.gmt_create is '创建时间';
comment on column public.tenant_info.gmt_modified is '修改时间';
create index if not exists idx_tenant_info_tenant_id
on public.tenant_info (tenant_id);
create table if not exists public.users
(
username varchar(50) not null
primary key,
password varchar(500) not null,
enabled boolean not null
);
create table if not exists public.roles
(
username varchar(50) not null,
role varchar(50) not null
);
create index if not exists idx_user_role
on public.roles (username, role);
create table if not exists public.permissions
(
role varchar(50) not null,
resource varchar(255) not null,
action varchar(8) not null
);
create index if not exists uk_role_permission
on public.permissions (role, resource, action);
INSERT INTO users (username, password, enabled)
VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', TRUE);
INSERT INTO roles (username, role)
VALUES ('nacos', 'ROLE_ADMIN');