-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.sql
67 lines (40 loc) · 1.21 KB
/
schema.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
BEGIN;
DROP TABLE IF EXISTS log_http;
DROP TABLE IF EXISTS log_stream;
DROP TABLE IF EXISTS log_error;
DROP TABLE IF EXISTS source;
DROP TYPE IF EXISTS source_type;
CREATE TYPE source_type AS ENUM ('web', 'raw', 'socket.io');
CREATE TABLE source(
id SERIAL PRIMARY KEY,
active BOOLEAN NOT NULL DEFAULT true,
normal_wait_secs INTEGER NOT NULL,
error_wait_secs INTEGER DEFAULT NULL,
protocol source_type NOT NULL,
address TEXT NOT NULL
);
CREATE TABLE log_error(
id SERIAL PRIMARY KEY,
src_id INTEGER NOT NULL REFERENCES source(id),
ts TIMESTAMP WITHOUT TIME ZONE NOT NULL,
error TEXT NOT NULL
);
CREATE TABLE log_stream(
id SERIAL PRIMARY KEY,
src_id INTEGER NOT NULL REFERENCES source(id),
ts_connection TIMESTAMP WITHOUT TIME ZONE,
ts_received TIMESTAMP WITHOUT TIME ZONE,
line_received TEXT NOT NULL
);
CREATE TABLE log_http(
id SERIAL PRIMARY KEY,
src_id INTEGER NOT NULL REFERENCES source(id),
ts_request_made TIMESTAMP WITHOUT TIME ZONE NOT NULL,
ts_headers_start TIMESTAMP WITHOUT TIME ZONE NOT NULL,
ts_content_start TIMESTAMP WITHOUT TIME ZONE NOT NULL,
ts_content_end TIMESTAMP WITHOUT TIME ZONE NOT NULL,
resp_code INTEGER,
resp_headers TEXT,
resp_content TEXT
);
COMMIT;