Projekt

Obecné

Profil

Stáhnout (2.85 KB) Statistiky
| Větev: | Tag: | Revize:
1
SCHEMA_SQL = """
2
/* ---------------------------------------------------- */
3
/*  Generated by Enterprise Architect Version 13.5 		*/
4
/*  Created On : 01-dub-2021 15:16:53 				*/
5
/*  DBMS       : SQLite 								*/
6
/* ---------------------------------------------------- */
7

    
8
/* Drop Tables */
9

    
10
DROP TABLE IF EXISTS 'PrivateKeys'
11
;
12

    
13
DROP TABLE IF EXISTS 'CertificateTypes'
14
;
15

    
16
DROP TABLE IF EXISTS 'UsageTypes'
17
;
18

    
19
DROP TABLE IF EXISTS 'Certificates'
20
;
21

    
22
DROP TABLE IF EXISTS 'CertificateUsages'
23
;
24

    
25
/* Create Tables with Primary and Foreign Keys, Check and Unique Constraints */
26

    
27
CREATE TABLE 'PrivateKeys'
28
(
29
	'id' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
30
	'private_key' TEXT NOT NULL,
31
	'password' TEXT NULL
32
)
33
;
34

    
35
CREATE TABLE 'CertificateTypes'
36
(
37
	'id' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
38
	'certificate_type' TEXT NOT NULL
39
)
40
;
41

    
42
CREATE TABLE 'UsageTypes'
43
(
44
	'id' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
45
	'usage_type' TEXT NOT NULL
46
)
47
;
48

    
49
CREATE TABLE 'Certificates'
50
(
51
	'id' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
52
	'common_name' TEXT NOT NULL,
53
	'valid_from' TEXT NOT NULL,
54
	'valid_to' TEXT NOT NULL,
55
	'pem_data' TEXT NOT NULL,
56
	'revocation_date' TEXT NULL,
57
	'revocation_reason' TEXT NULL,
58
	'private_key_id' INTEGER NOT NULL,
59
	'certificate_type_id' INTEGER NOT NULL,
60
	'parent_certificate_id' INTEGER NOT NULL,
61
	CONSTRAINT 'FK_Certificates' FOREIGN KEY ('parent_certificate_id') REFERENCES 'Certificates' ('id') ON DELETE No Action ON UPDATE No Action,
62
	CONSTRAINT 'FK_CertificateTypes' FOREIGN KEY ('certificate_type_id') REFERENCES 'CertificateTypes' ('id') ON DELETE No Action ON UPDATE No Action,
63
	CONSTRAINT 'FK_PrivateKeys' FOREIGN KEY ('private_key_id') REFERENCES 'PrivateKeys' ('id') ON DELETE No Action ON UPDATE No Action
64
)
65
;
66

    
67
CREATE TABLE 'CertificateUsages'
68
(
69
	'id' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
70
	'certificate_id' INTEGER NOT NULL,
71
	'usage_type_id' INTEGER NOT NULL,
72
	CONSTRAINT 'FK_Certificates' FOREIGN KEY ('certificate_id') REFERENCES 'Certificates' ('id') ON DELETE Cascade ON UPDATE No Action,
73
	CONSTRAINT 'FK_UsageTypes' FOREIGN KEY ('usage_type_id') REFERENCES 'UsageTypes' ('id') ON DELETE No Action ON UPDATE No Action
74
)
75
;
76

    
77
"""
78

    
79
DEFAULT_VALUES_SQL = """
80
/* ---------------------------------------------------- */
81
/*  Generated by Enterprise Architect Version 13.5 		*/
82
/*  Created On : 26-bře-2021 13:33:05 				*/
83
/*  DBMS       : SQLite 								*/
84
/* ---------------------------------------------------- */
85

    
86
/* Insert default values */
87

    
88
INSERT INTO CertificateTypes(certificate_type) VALUES('ROOT_CA');
89
INSERT INTO CertificateTypes(certificate_type) VALUES('INTERMEDIATE_CA');
90
INSERT INTO CertificateTypes(certificate_type) VALUES('CERTIFICATE');
91

    
92
INSERT INTO UsageTypes(usage_type) VALUES('CA');
93
INSERT INTO UsageTypes(usage_type) VALUES('SSL');
94
INSERT INTO UsageTypes(usage_type) VALUES('SIGNATURE');
95
INSERT INTO UsageTypes(usage_type) VALUES('AUTHENTICATION');
96

    
97
"""
(2-2/3)