CREATE TABLE IF NOT EXISTS tracker_rules (
    id              INTEGER PRIMARY KEY AUTOINCREMENT,
    tracker_id      TEXT NOT NULL REFERENCES trackers(id),
    rule_key        TEXT NOT NULL,
    rule_value_json TEXT NOT NULL,
    source_file     TEXT,
    loaded_at       INTEGER NOT NULL,
    UNIQUE(tracker_id, rule_key)
);
CREATE INDEX IF NOT EXISTS idx_tracker_rules_lookup
    ON tracker_rules(tracker_id, rule_key);
