Geoffrey Frogeye
57416b6e2c
Mostly for performances reasons. First one to implement threading later. Second one to speed up the dichotomy, but it doesn't seem that much better so far.
52 lines
1.5 KiB
SQL
52 lines
1.5 KiB
SQL
-- Remember to increment DB_VERSION
|
|
-- in database.py on changes to this file
|
|
|
|
CREATE TABLE rules (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
source INTEGER, -- The rule this one is based on
|
|
updated INTEGER, -- If the row was updated during last data import (0: No, 1: Yes)
|
|
first_party INTEGER, -- 1: this blocks a first party for sure, 0: maybe
|
|
refs INTEGER, -- Number of entries issued from this one
|
|
level INTEGER, -- Level of recursion to the root source rule (used for source priority)
|
|
FOREIGN KEY (source) REFERENCES rules(id) ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE asn (
|
|
val INTEGER PRIMARY KEY,
|
|
entry INTEGER,
|
|
FOREIGN KEY (entry) REFERENCES rules(id) ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE hostname (
|
|
val TEXT PRIMARY KEY, -- rev'd, ends with a dot (for consistency with zone)
|
|
entry INTEGER,
|
|
FOREIGN KEY (entry) REFERENCES rules(id) ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE zone (
|
|
val TEXT PRIMARY KEY, -- rev'd, ends with a dot (for easier matching)
|
|
entry INTEGER,
|
|
FOREIGN KEY (entry) REFERENCES rules(id) ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE ip4address (
|
|
val INTEGER PRIMARY KEY,
|
|
entry INTEGER,
|
|
FOREIGN KEY (entry) REFERENCES rules(id) ON DELETE CASCADE
|
|
);
|
|
|
|
CREATE TABLE ip4network (
|
|
-- val TEXT PRIMARY KEY,
|
|
mini INTEGER,
|
|
maxi INTEGER,
|
|
entry INTEGER,
|
|
FOREIGN KEY (entry) REFERENCES rules(id) ON DELETE CASCADE
|
|
);
|
|
CREATE INDEX ip4network_minmax ON ip4network (mini, maxi);
|
|
|
|
-- Store various things
|
|
CREATE TABLE meta (
|
|
key TEXT PRIMARY KEY,
|
|
value integer
|
|
);
|