mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-15 10:43:55 +00:00
Add adlist_groups and mark group_id columns as NOT NULL.
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
parent
c53ee4202b
commit
cbc210b014
2 changed files with 18 additions and 6 deletions
|
@ -15,7 +15,7 @@ CREATE TABLE whitelist
|
||||||
enabled BOOLEAN NOT NULL DEFAULT 1,
|
enabled BOOLEAN NOT NULL DEFAULT 1,
|
||||||
date_added INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)),
|
date_added INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)),
|
||||||
date_modified INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)),
|
date_modified INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)),
|
||||||
group_id INTEGER DEFAULT 0,
|
group_id INTEGER NOT NULL DEFAULT 0,
|
||||||
comment TEXT,
|
comment TEXT,
|
||||||
FOREIGN KEY (group_id) REFERENCES domain_groups(id)
|
FOREIGN KEY (group_id) REFERENCES domain_groups(id)
|
||||||
);
|
);
|
||||||
|
@ -26,7 +26,7 @@ CREATE TABLE blacklist
|
||||||
enabled BOOLEAN NOT NULL DEFAULT 1,
|
enabled BOOLEAN NOT NULL DEFAULT 1,
|
||||||
date_added INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)),
|
date_added INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)),
|
||||||
date_modified INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)),
|
date_modified INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)),
|
||||||
group_id INTEGER DEFAULT 0,
|
group_id INTEGER NOT NULL DEFAULT 0,
|
||||||
comment TEXT,
|
comment TEXT,
|
||||||
FOREIGN KEY (group_id) REFERENCES domain_groups(id)
|
FOREIGN KEY (group_id) REFERENCES domain_groups(id)
|
||||||
);
|
);
|
||||||
|
@ -37,10 +37,19 @@ CREATE TABLE regex
|
||||||
enabled BOOLEAN NOT NULL DEFAULT 1,
|
enabled BOOLEAN NOT NULL DEFAULT 1,
|
||||||
date_added INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)),
|
date_added INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)),
|
||||||
date_modified INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)),
|
date_modified INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)),
|
||||||
group_id INTEGER DEFAULT 0,
|
group_id INTEGER NOT NULL DEFAULT 0,
|
||||||
comment TEXT,
|
comment TEXT,
|
||||||
FOREIGN KEY (group_id) REFERENCES domain_groups(id)
|
FOREIGN KEY (group_id) REFERENCES domain_groups(id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE TABLE adlist_groups
|
||||||
|
(
|
||||||
|
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"enabled" BOOLEAN NOT NULL DEFAULT 1,
|
||||||
|
"description" TEXT
|
||||||
|
);
|
||||||
|
INSERT INTO adlist_groups ("id","description") VALUES (0,'Standard group');
|
||||||
|
|
||||||
CREATE TABLE adlists
|
CREATE TABLE adlists
|
||||||
(
|
(
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
@ -48,7 +57,9 @@ CREATE TABLE adlists
|
||||||
enabled BOOLEAN NOT NULL DEFAULT 1,
|
enabled BOOLEAN NOT NULL DEFAULT 1,
|
||||||
date_added INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)),
|
date_added INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)),
|
||||||
date_modified INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)),
|
date_modified INTEGER NOT NULL DEFAULT (cast(strftime('%s', 'now') as int)),
|
||||||
comment TEXT
|
group_id INTEGER NOT NULL DEFAULT 0,
|
||||||
|
comment TEXT,
|
||||||
|
FOREIGN KEY (group_id) REFERENCES adlist_groups(id)
|
||||||
);
|
);
|
||||||
CREATE TABLE gravity
|
CREATE TABLE gravity
|
||||||
(
|
(
|
||||||
|
@ -101,7 +112,8 @@ CREATE TRIGGER tr_regex_update AFTER UPDATE ON regex
|
||||||
|
|
||||||
CREATE VIEW vw_adlists AS SELECT a.address
|
CREATE VIEW vw_adlists AS SELECT a.address
|
||||||
FROM adlists a
|
FROM adlists a
|
||||||
WHERE a.enabled == 1
|
INNER JOIN adlist_groups b ON b.id = a.group_id
|
||||||
|
WHERE a.enabled = 1 AND b.enabled = 1
|
||||||
ORDER BY a.id;
|
ORDER BY a.id;
|
||||||
|
|
||||||
CREATE TRIGGER tr_adlists_update AFTER UPDATE ON adlists
|
CREATE TRIGGER tr_adlists_update AFTER UPDATE ON adlists
|
||||||
|
|
|
@ -120,7 +120,7 @@ database_table_from_file() {
|
||||||
do
|
do
|
||||||
# Only add non-empty lines
|
# Only add non-empty lines
|
||||||
if [[ ! -z "${domain}" ]]; then
|
if [[ ! -z "${domain}" ]]; then
|
||||||
echo "${rowid},\"${domain}\",1,${timestamp},${timestamp},\"Migrated from ${source}\"" >> "${tmpFile}"
|
echo "${rowid},\"${domain}\",1,${timestamp},${timestamp},0,\"Migrated from ${source}\"" >> "${tmpFile}"
|
||||||
rowid+=1
|
rowid+=1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue