summaryrefslogtreecommitdiff
path: root/backend/node/src/clipperz.schema.sql
blob: 1c2305c7c04143fe6b42db774d14fbf65ca57df4 (plain)
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
CREATE SCHEMA clipperz;

CREATE TABLE clipperz.theuser (
 u_id serial PRIMARY KEY,
 u_name varchar NOT NULL UNIQUE,
 u_srp_s varchar NOT NULL,
 u_srp_v varchar NOT NULL,
 u_header json NOT NULL,
 u_statistics varchar NOT NULL,
 u_authversion varchar NOT NULL,
 u_version varchar NOT NULL,
 u_lock varchar NOT NULL
);

CREATE TABLE clipperz.therecord (
 r_id serial PRIMARY KEY,
 u_id integer NOT NULL REFERENCES clipperz.theuser(u_id) ON UPDATE CASCADE ON DELETE CASCADE,
 r_ref varchar NOT NULL UNIQUE,
 r_data varchar NOT NULL,
 r_version varchar NOT NULL,
 r_ctime timestamp NOT NULL DEFAULT current_timestamp,
 r_mtime timestamp NOT NULL DEFAULT current_timestamp,
 r_atime timestamp NOT NULL DEFAULT current_timestamp
);
CREATE INDEX therecord_u_id_key ON clipperz.therecord (u_id);

CREATE TABLE clipperz.therecordversion (
 rv_id serial PRIMARY KEY,
 r_id integer NOT NULL REFERENCES clipperz.therecord (r_id) ON UPDATE CASCADE ON DELETE CASCADE,
 rv_ref varchar NOT NULL UNIQUE,
 rv_header varchar,
 rv_data varchar NOT NULL,
 rv_version varchar NOT NULL,
 rv_previous_key varchar NOT NULL,
 rv_previous_id varchar,
 rv_ctime timestamp NOT NULL DEFAULT current_timestamp,
 rv_mtime timestamp NOT NULL DEFAULT current_timestamp,
 rv_atime timestamp NOT NULL DEFAULT current_timestamp
);

CREATE TABLE clipperz.otpstatus (
 otps_id serial PRIMARY KEY,
 otps_code varchar NOT NULL,
 otps_name varchar NOT NULL,
 otps_desc varchar NOT NULL
);

CREATE TABLE clipperz.theotp (
 otp_id serial PRIMARY KEY,
 u_id integer REFERENCES clipperz.theuser (u_id) ON UPDATE CASCADE ON DELETE CASCADE,
 otps_id integer REFERENCES clipperz.otpstatus (otps_id) ON UPDATE CASCADE ON DELETE CASCADE,
 otp_ref varchar NOT NULL UNIQUE,
 otp_key varchar NOT NULL UNIQUE,
 otp_key_checksum varchar NOT NULL,
 otp_data varchar NOT NULL,
 otp_version varchar NOT NULL,
 otp_ctime timestamp NOT NULL DEFAULT current_timestamp,
 otp_rtime timestamp NOT NULL DEFAULT current_timestamp,
 otp_utime timestamp NOT NULL DEFAULT current_timestamp
);

CREATE TABLE clipperz.thesession (
 s_id varchar PRIMARY KEY,
 s_data json,
 s_ctime timestamp DEFAULT current_timestamp,
 s_mtime timestamp DEFAULT current_timestamp
);