/
01_tables.sql
357 lines (319 loc) · 10.6 KB
/
01_tables.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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
create sequence admin_id_seq start 1 increment 1;
create sequence audit_log_id_seq start 1 increment 1;
create sequence authority_instance_reference_id_seq start 1 increment 1;
create sequence certificate_content_id_seq start 1 increment 1;
create sequence group_id_seq start 1 increment 1;
create sequence entity_id_seq start 1 increment 1;
create sequence certificate_id_seq start 1 increment 1;
create sequence client_id_seq start 1 increment 1;
create sequence connector_2_function_group_id_seq start 1 increment 1;
create sequence connector_id_seq start 1 increment 1;
create sequence credential_id_seq start 1 increment 1;
create sequence discovery_certificate_id_seq start 1 increment 1;
create sequence discovery_id_seq start 1 increment 1;
create sequence endpoint_id_seq start 1 increment 1;
create sequence function_group_id_seq start 1 increment 1;
create sequence ra_profile_id_seq start 1 increment 1;
create table admin (
id int8 not null,
uuid varchar(255),
i_author varchar(255),
i_cre timestamp not null,
i_upd timestamp not null,
description varchar(255),
email varchar(255),
enabled boolean,
name varchar(255),
role varchar(255),
serial_number varchar(255),
surname varchar(255),
username varchar(255),
certificate_id int8 not null,
primary key (id)
);
create table audit_log (
id int8 not null,
uuid varchar(255),
i_author varchar(255),
i_cre timestamp not null,
i_upd timestamp not null,
additional_data text,
affected varchar(255),
object_identifier varchar(255),
operation varchar(255),
operation_status varchar(255),
origination varchar(255),
primary key (id)
);
create table authority_instance_reference (
id int8 not null,
uuid varchar(255),
i_author varchar(255),
i_cre timestamp not null,
i_upd timestamp not null,
kind varchar(255),
authority_instance_uuid varchar(255),
connector_name varchar(255),
name varchar(255),
status varchar(255),
connector_id int8,
primary key (id)
);
CREATE TABLE "certificate" (
"common_name" VARCHAR,
"serial_number" VARCHAR NOT NULL,
"i_author" VARCHAR NULL DEFAULT NULL,
"i_cre" TIMESTAMP NOT NULL,
"i_upd" TIMESTAMP NOT NULL,
"issuer_common_name" VARCHAR NULL DEFAULT '',
"issuer_dn" VARCHAR NOT NULL DEFAULT '',
"subject_dn" VARCHAR NOT NULL DEFAULT '',
"not_before" TIMESTAMP NOT NULL,
"not_after" TIMESTAMP NOT NULL,
"public_key_algorithm" VARCHAR NOT NULL DEFAULT '',
"signature_algorithm" VARCHAR NOT NULL DEFAULT '',
"key_size" INTEGER NULL DEFAULT NULL,
"basic_constraints" VARCHAR NULL DEFAULT NULL,
"extended_key_usage" TEXT NULL DEFAULT NULL,
"id" BIGINT NOT NULL,
"uuid" VARCHAR NOT NULL,
"discovery_uuid" BIGINT NULL DEFAULT NULL,
"status" VARCHAR NULL DEFAULT 'Unassigned',
"ra_profile_id" BIGINT NULL DEFAULT NULL,
"fingerprint" VARCHAR NULL DEFAULT NULL,
"subject_alternative_names" TEXT NULL DEFAULT NULL,
"meta" TEXT NULL DEFAULT NULL,
"entity_id" BIGINT NULL DEFAULT NULL,
"group_id" BIGINT NULL DEFAULT NULL,
"owner" VARCHAR NULL DEFAULT '',
"key_usage" TEXT NULL DEFAULT '',
"certificate_type" VARCHAR NULL DEFAULT '',
"issuer_serial_number" VARCHAR NULL DEFAULT NULL,
"certificate_validation_result" TEXT NULL DEFAULT '',
"certificate_content_id" BIGINT NULL DEFAULT NULL,
PRIMARY KEY ("id")
)
;
CREATE TABLE "certificate_content" (
"id" BIGINT NOT NULL,
"fingerprint" VARCHAR NOT NULL,
"content" VARCHAR NOT NULL,
PRIMARY KEY ("id")
)
;
CREATE TABLE "certificate_entity" (
"id" BIGINT NOT NULL,
"name" VARCHAR NOT NULL,
"uuid" VARCHAR NOT NULL,
"entity_type" VARCHAR NOT NULL,
"i_author" VARCHAR NULL DEFAULT NULL,
"i_cre" DATE NULL DEFAULT NULL,
"i_upd" DATE NULL DEFAULT NULL,
"description" VARCHAR NULL DEFAULT NULL,
PRIMARY KEY ("id")
);
CREATE TABLE "certificate_group" (
"id" BIGINT NOT NULL,
"uuid" VARCHAR NOT NULL,
"name" VARCHAR NOT NULL,
"description" VARCHAR NULL DEFAULT NULL,
"i_author" VARCHAR NULL DEFAULT NULL,
"i_cre" DATE NULL DEFAULT NULL,
"i_upd" DATE NULL DEFAULT NULL,
primary key (id)
);
create table client (
id int8 not null,
uuid varchar(255),
i_author varchar(255),
i_cre timestamp not null,
i_upd timestamp not null,
description varchar(255),
enabled boolean,
name varchar(255),
serial_number varchar(255),
certificate_id int8 not null,
primary key (id)
);
create table client_authorization (
ra_profile_id int8 not null,
client_id int8 not null,
primary key (ra_profile_id, client_id)
);
create table connector (
id int8 not null,
uuid varchar(255),
i_author varchar(255),
i_cre timestamp not null,
i_upd timestamp not null,
auth_attributes text,
auth_type varchar(255),
name varchar(255),
status varchar(255),
url varchar(255),
primary key (id)
);
create table connector_2_function_group (
id int8 not null,
kinds varchar(255),
connector_id int8 not null,
function_group_id int8 not null,
primary key (id)
);
create table credential (
id int8 not null,
uuid varchar(255),
i_author varchar(255),
i_cre timestamp not null,
i_upd timestamp not null,
attributes text,
connector_name varchar(255),
enabled boolean,
name varchar(255),
kind varchar(255),
connector_id int8,
primary key (id)
);
CREATE TABLE "discovery_history" (
"status" VARCHAR NOT NULL,
"start_time" TIMESTAMP NULL DEFAULT NULL,
"end_time" TIMESTAMP NULL DEFAULT NULL,
"total_certificates_discovered" INTEGER NULL DEFAULT NULL,
"i_author" VARCHAR NULL DEFAULT NULL,
"i_cre" TIMESTAMP NULL DEFAULT NULL,
"i_upd" TIMESTAMP NULL DEFAULT NULL,
"id" BIGINT NOT NULL,
"uuid" VARCHAR NOT NULL,
"connector_uuid" VARCHAR NOT NULL,
"name" VARCHAR NOT NULL,
"attributes" TEXT NULL DEFAULT NULL,
"meta" TEXT NULL DEFAULT NULL,
"message" TEXT NULL DEFAULT NULL,
"kind" VARCHAR NULL DEFAULT NULL,
"connector_name" VARCHAR NULL DEFAULT NULL,
PRIMARY KEY ("id")
)
;
CREATE TABLE "discovery_certificate" (
"id" BIGINT NOT NULL,
"uuid" VARCHAR NOT NULL,
"common_name" VARCHAR NULL,
"serial_number" VARCHAR NOT NULL,
"issuer_common_name" VARCHAR NULL DEFAULT NULL,
"not_before" VARCHAR NOT NULL,
"not_after" VARCHAR NOT NULL,
"i_author" VARCHAR NULL DEFAULT NULL,
"i_cre" VARCHAR NULL DEFAULT NULL,
"i_upd" VARCHAR NULL DEFAULT NULL,
"certificate_content_id" BIGINT NOT NULL,
"discovery_id" BIGINT NULL DEFAULT NULL,
PRIMARY KEY ("id")
)
;
create table endpoint (
id int8 not null,
uuid varchar(255),
context varchar(255),
method varchar(255),
name varchar(255),
required boolean,
function_group_id int8 not null,
primary key (id)
);
create table function_group (
id int8 not null,
uuid varchar(255),
code varchar(255),
name varchar(255),
primary key (id)
);
create table ra_profile (
id int8 not null,
uuid varchar(255),
i_author varchar(255),
i_cre timestamp not null,
i_upd timestamp not null,
attributes text,
authority_instance_name varchar(255),
description varchar(255),
enabled boolean,
name varchar(255),
authority_instance_ref_id int8,
primary key (id)
);
alter table if exists admin
add constraint FKrq5yjsxacu7105ihrfcp662xe
foreign key (certificate_id)
references certificate;
alter table if exists authority_instance_reference
add constraint FK2t7xntc30lq9crkgdfntk6hsh
foreign key (connector_id)
references connector;
alter table if exists certificate
add constraint FK2ybpa8h8jjfv2cjw76hvv6etw
foreign key (certificate_content_id)
references certificate_content;
alter table if exists certificate
add constraint FKdiwwxixt707t6nquu7d8k7gga
foreign key (entity_id)
references certificate_entity;
alter table if exists certificate
add constraint FKcuayu1tjhuojrg3c28i2uqi4g
foreign key (group_id)
references certificate_group;
alter table if exists certificate
add constraint FK41nap2d0f529tuabyjs424a80
foreign key (ra_profile_id)
references ra_profile;
alter table if exists client
add constraint FKlyok3m28dnf8lr2gevt5aj2np
foreign key (certificate_id)
references certificate;
alter table if exists client_authorization
add constraint FKkjs42uvpsdos793wflp2onl3s
foreign key (client_id)
references client;
alter table if exists client_authorization
add constraint FKdn5d25h79l2el4iv9w7isnnjc
foreign key (ra_profile_id)
references ra_profile;
alter table if exists connector_2_function_group
add constraint FK1qvna5aqsvmfwsxr90q9ewsk3
foreign key (connector_id)
references connector;
alter table if exists connector_2_function_group
add constraint FKe04tlwcpn0a6otrw84gke8k3d
foreign key (function_group_id)
references function_group;
alter table if exists credential
add constraint FKrxdkw4wef9tt0fbx5t892wv59
foreign key (connector_id)
references connector;
alter table if exists discovery_certificate
add constraint FKgmcpy0hkmray7pk0hvqpc4nwc
foreign key (certificate_content_id)
references certificate_content;
alter table if exists discovery_certificate
add constraint FK4uptmj2ejf9i1cfjnikmesa5p
foreign key (discovery_id)
references discovery_history;
alter table if exists endpoint
add constraint FKgj4l79prijfj4nnjl7idi27be
foreign key (function_group_id)
references function_group;
alter table if exists ra_profile
add constraint FK1ybgp06wf8uoegwfhsg4fev2a
foreign key (authority_instance_ref_id)
references authority_instance_reference;
ALTER TABLE if exists client
ADD CONSTRAINT client_name_unique
UNIQUE (name);
ALTER TABLE if exists admin
ADD CONSTRAINT admin_username_unique
UNIQUE (username);
ALTER TABLE if exists certificate
ADD CONSTRAINT certificate_uuid_unique
UNIQUE (uuid);
ALTER TABLE if exists discovery_history
ADD CONSTRAINT discovery_uuid_unique
UNIQUE (uuid);