mirror of
https://github.com/tnodir/fort
synced 2024-11-15 05:46:03 +00:00
UI: ConfManager: Refactor "rule" table
This commit is contained in:
parent
ed9fab07c9
commit
6c7c310ab0
@ -32,7 +32,7 @@ namespace {
|
||||
|
||||
const QLoggingCategory LC("conf");
|
||||
|
||||
constexpr int DATABASE_USER_VERSION = 34;
|
||||
constexpr int DATABASE_USER_VERSION = 35;
|
||||
|
||||
const char *const sqlSelectAddressGroups = "SELECT addr_group_id, include_all, exclude_all,"
|
||||
" include_zones, exclude_zones,"
|
||||
|
@ -34,8 +34,6 @@ const char *const sqlDeleteRule = "DELETE FROM rule WHERE rule_id = ?1;";
|
||||
|
||||
const char *const sqlDeleteAppRule = "DELETE FROM app_rule WHERE rule_id = 1;";
|
||||
|
||||
const char *const sqlDeleteSystemRule = "DELETE FROM system_rule WHERE rule_id = 1;";
|
||||
|
||||
const char *const sqlUpdateRuleName = "UPDATE rule SET name = ?2 WHERE rule_id = ?1;";
|
||||
|
||||
const char *const sqlUpdateRuleEnabled = "UPDATE rule SET enabled = ?2 WHERE rule_id = ?1;";
|
||||
@ -133,9 +131,6 @@ bool ConfRuleManager::deleteRule(int ruleId)
|
||||
if (ok) {
|
||||
// Delete the Rule from App Rules
|
||||
sqliteDb()->executeEx(sqlDeleteAppRule, vars, 0, &ok);
|
||||
|
||||
// Delete the Rule from System Rules
|
||||
sqliteDb()->executeEx(sqlDeleteSystemRule, vars, 0, &ok);
|
||||
}
|
||||
|
||||
commitTransaction(ok);
|
||||
|
@ -92,33 +92,23 @@ CREATE TABLE rule(
|
||||
name TEXT NOT NULL,
|
||||
notes TEXT,
|
||||
rule_text TEXT NOT NULL,
|
||||
rule_type INTEGER NOT NULL, -- app rules (1..64), global before/after apps (65..96, 97..128), preset rules (129..255)
|
||||
accept_zones INTEGER NOT NULL DEFAULT 0, -- zone indexes bit mask
|
||||
reject_zones INTEGER NOT NULL DEFAULT 0, -- zone indexes bit mask
|
||||
mod_time INTEGER NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX rule_name_idx ON rule(name);
|
||||
CREATE INDEX rule_rule_type_name_idx ON rule(rule_type, name);
|
||||
|
||||
CREATE TABLE app_rule(
|
||||
app_rule_id INTEGER PRIMARY KEY,
|
||||
app_id INTEGER NOT NULL,
|
||||
order_index INTEGER NOT NULL,
|
||||
rule_id INTEGER NOT NULL
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX app_rule_app_id_order_index_uk ON app_rule(app_id, order_index);
|
||||
CREATE INDEX app_rule_app_id_idx ON app_rule(app_id);
|
||||
CREATE INDEX app_rule_rule_id_idx ON app_rule(rule_id);
|
||||
|
||||
CREATE TABLE system_rule(
|
||||
system_rule_id INTEGER PRIMARY KEY,
|
||||
system_type INTEGER NOT NULL, -- before/after apps
|
||||
order_index INTEGER NOT NULL,
|
||||
rule_id INTEGER NOT NULL
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX system_rule_system_type_order_index_uk ON system_rule(system_type, order_index);
|
||||
CREATE INDEX system_rule_rule_id_idx ON system_rule(rule_id);
|
||||
|
||||
CREATE TABLE task(
|
||||
task_id INTEGER PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
|
Loading…
Reference in New Issue
Block a user