-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathcreate_table.sql
More file actions
39 lines (35 loc) · 1.01 KB
/
create_table.sql
File metadata and controls
39 lines (35 loc) · 1.01 KB
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
CREATE TYPE STATES AS ENUM ('new', 'false_positive', 'addressing', 'not_relevant', 'fixed');
CREATE TYPE CATEGORIES AS ENUM ('password', 'token', 'crypto_key', 'other');
CREATE TABLE repos (
url TEXT NOT NULL UNIQUE,
last_scan INTEGER,
PRIMARY KEY (url)
);
CREATE TABLE rules (
id SERIAL NOT NULL UNIQUE,
regex TEXT NOT NULL UNIQUE,
category CATEGORIES,
description TEXT,
PRIMARY KEY (id)
);
CREATE TABLE discoveries (
id SERIAL NOT NULL UNIQUE,
file_name TEXT NOT NULL,
commit_id TEXT NOT NULL,
line_number INTEGER DEFAULT -1,
snippet TEXT DEFAULT '',
repo_url TEXT,
rule_id INTEGER,
state STATES NOT NULL DEFAULT 'new',
timestamp TEXT NOT NULL DEFAULT timeofday(),
PRIMARY KEY (id),
FOREIGN KEY (repo_url) REFERENCES repos ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (rule_id) REFERENCES rules ON DELETE SET NULL ON UPDATE CASCADE
);
CREATE TABLE embeddings (
id INTEGER REFERENCES discoveries,
snippet TEXT,
embedding TEXT,
repo_url TEXT REFERENCES repos,
PRIMARY KEY (id)
);