2019-05-01 15:57:23 +00:00
|
|
|
CREATE TABLE whitelist
|
|
|
|
(
|
|
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
|
|
domain TEXT UNIQUE NOT NULL,
|
|
|
|
enabled BOOLEAN NOT NULL DEFAULT 1,
|
|
|
|
date_added INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)),
|
|
|
|
date_modified INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)),
|
|
|
|
comment TEXT
|
|
|
|
);
|
|
|
|
CREATE TABLE blacklist
|
|
|
|
(
|
|
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
|
|
domain TEXT UNIQUE NOT NULL,
|
|
|
|
enabled BOOLEAN NOT NULL DEFAULT 1,
|
|
|
|
date_added INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)),
|
|
|
|
date_modified INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)),
|
|
|
|
comment TEXT
|
|
|
|
);
|
|
|
|
CREATE TABLE regex
|
|
|
|
(
|
|
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
|
|
domain TEXT UNIQUE NOT NULL,
|
|
|
|
enabled BOOLEAN NOT NULL DEFAULT 1,
|
|
|
|
date_added INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)),
|
|
|
|
date_modified INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)),
|
|
|
|
comment TEXT
|
|
|
|
);
|
|
|
|
CREATE TABLE adlists
|
|
|
|
(
|
|
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
|
|
address TEXT UNIQUE NOT NULL,
|
|
|
|
enabled BOOLEAN NOT NULL DEFAULT 1,
|
|
|
|
date_added INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)),
|
|
|
|
date_modified INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)),
|
|
|
|
comment TEXT
|
|
|
|
);
|
|
|
|
CREATE TABLE gravity
|
|
|
|
(
|
|
|
|
domain TEXT UNIQUE NOT NULL
|
|
|
|
);
|
|
|
|
CREATE TABLE info
|
|
|
|
(
|
|
|
|
property TEXT NOT NULL,
|
|
|
|
value TEXT NOT NULL
|
|
|
|
);
|
2019-02-06 17:57:48 +00:00
|
|
|
|
|
|
|
INSERT INTO info VALUES("version","1");
|
2019-02-05 18:05:11 +00:00
|
|
|
|
2019-05-01 14:37:23 +00:00
|
|
|
CREATE VIEW vw_gravity AS SELECT a.domain
|
2019-04-29 17:43:35 +00:00
|
|
|
FROM gravity a
|
|
|
|
WHERE a.domain NOT IN (SELECT domain from whitelist WHERE enabled == 1);
|
2019-02-05 18:05:11 +00:00
|
|
|
|
2019-05-01 14:37:23 +00:00
|
|
|
CREATE VIEW vw_whitelist AS SELECT a.domain
|
2019-04-29 17:43:35 +00:00
|
|
|
FROM whitelist a
|
2019-05-01 15:50:36 +00:00
|
|
|
WHERE a.enabled == 1
|
|
|
|
ORDER BY a.id;
|
|
|
|
|
2019-04-29 17:43:35 +00:00
|
|
|
CREATE TRIGGER tr_whitelist_update AFTER UPDATE ON whitelist
|
|
|
|
BEGIN
|
|
|
|
UPDATE whitelist SET date_modified = (cast(strftime('%s', 'now') as int)) WHERE domain = NEW.domain;
|
2019-05-01 14:38:41 +00:00
|
|
|
END;
|
2019-02-05 18:05:11 +00:00
|
|
|
|
2019-05-01 14:37:23 +00:00
|
|
|
CREATE VIEW vw_blacklist AS SELECT a.domain
|
2019-04-29 17:43:35 +00:00
|
|
|
FROM blacklist a
|
2019-05-01 15:50:36 +00:00
|
|
|
WHERE a.enabled == 1 AND a.domain NOT IN vw_whitelist
|
|
|
|
ORDER BY a.id;
|
|
|
|
|
2019-04-29 17:43:35 +00:00
|
|
|
CREATE TRIGGER tr_blacklist_update AFTER UPDATE ON blacklist
|
|
|
|
BEGIN
|
|
|
|
UPDATE blacklist SET date_modified = (cast(strftime('%s', 'now') as int)) WHERE domain = NEW.domain;
|
2019-05-01 14:38:41 +00:00
|
|
|
END;
|
2019-04-28 12:42:52 +00:00
|
|
|
|
2019-05-01 14:37:23 +00:00
|
|
|
CREATE VIEW vw_regex AS SELECT a.domain
|
2019-04-29 17:43:35 +00:00
|
|
|
FROM regex a
|
2019-05-01 15:50:36 +00:00
|
|
|
WHERE a.enabled == 1
|
|
|
|
ORDER BY a.id;
|
|
|
|
|
2019-04-29 17:43:35 +00:00
|
|
|
CREATE TRIGGER tr_regex_update AFTER UPDATE ON regex
|
|
|
|
BEGIN
|
|
|
|
UPDATE regex SET date_modified = (cast(strftime('%s', 'now') as int)) WHERE domain = NEW.domain;
|
2019-05-01 14:38:41 +00:00
|
|
|
END;
|
2019-04-26 15:36:00 +00:00
|
|
|
|
2019-05-01 14:37:23 +00:00
|
|
|
CREATE VIEW vw_adlists AS SELECT a.address
|
2019-04-29 17:43:35 +00:00
|
|
|
FROM adlists a
|
2019-05-01 15:50:36 +00:00
|
|
|
WHERE a.enabled == 1
|
|
|
|
ORDER BY a.id;
|
|
|
|
|
2019-04-29 17:43:35 +00:00
|
|
|
CREATE TRIGGER tr_adlists_update AFTER UPDATE ON adlists
|
|
|
|
BEGIN
|
|
|
|
UPDATE adlists SET date_modified = (cast(strftime('%s', 'now') as int)) WHERE address = NEW.address;
|
2019-05-01 14:38:41 +00:00
|
|
|
END;
|
2019-04-29 17:43:35 +00:00
|
|
|
|