Skip to content
Snippets Groups Projects
Verified Commit 38aad760 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

Plugin history: Tables

Create the table for the plugin history storage. Update the clean up
script, so the history is cleaned up accordingly.
parent ecef8b09
No related merge requests found
......@@ -17,6 +17,7 @@ DROP TABLE IF EXISTS fake_logs;
DROP TABLE IF EXISTS fake_server_names;
DROP TABLE IF EXISTS fake_blacklist_limits;
DROP TABLE IF EXISTS fake_blacklist_scores;
DROP TABLE IF EXISTS plugin_history;
DROP TABLE IF EXISTS known_plugins;
DROP TABLE IF EXISTS active_plugins;
DROP TABLE IF EXISTS ssh_commands;
......@@ -105,6 +106,18 @@ CREATE TABLE active_plugins (
UNIQUE(client, name),
FOREIGN KEY (client) REFERENCES clients(id)
);
CREATE TABLE plugin_history (
id BIGINT NOT NULL PRIMARY KEY,
client INT NOT NULL,
name TEXT NOT NULL,
timestamp TIMESTAMP NOT NULL,
version INT,
hash TEXT,
active BOOL NOT NULL,
FOREIGN KEY (client) REFERENCES clients(id)
);
CREATE SEQUENCE plugin_history_id OWNED BY plugin_history.id;
ALTER TABLE plugin_history ALTER COLUMN id SET DEFAULT NEXTVAL('plugin_history_id');
CREATE OR REPLACE VIEW plugin_activity AS SELECT
clients.name,
MIN(globals.last) AS last,
......@@ -678,6 +691,8 @@ GRANT SELECT ON known_plugins TO $DBUPDATER;
GRANT DELETE ON active_plugins TO $DBUPDATER;
GRANT INSERT ON active_plugins TO $DBUPDATER;
GRANT SELECT ON active_plugins TO $DBUPDATER;
GRANT INSERT ON plugin_history TO $DBUPDATER;
GRANT ALL ON plugin_history_id TO $DBUPDATER;
GRANT SELECT (name, passwd, mechanism, builtin_passwd, slot_id) ON clients TO $DBAUTHENTICATOR;
......@@ -719,6 +734,10 @@ GRANT DELETE ON refused TO $DBCLEANER;
GRANT DELETE ON ssh_sessions TO $DBCLEANER;
GRANT DELETE ON ssh_commands TO $DBCLEANER;
GRANT SELECT ON fake_logs TO $DBCLEANER;
GRANT SELECT ON plugin_history TO $DBCLEANER;
GRANT INSERT ON plugin_history TO $DBCLEANER;
GRANT DELETE ON plugin_history TO $DBCLEANER;
GRANT ALL ON plugin_history_id TO $DBUPDATER;
GRANT SELECT ON groups TO $DBARCHIVIST;
GRANT SELECT ON count_types TO $DBARCHIVIST;
......
......@@ -4,7 +4,7 @@ set -ex
. ./dbconfig
TABLES='activities anomalies count_snapshots bandwidth bandwidth_stats bandwidth_stats_dbg refused fake_logs'
TABLES='activities anomalies count_snapshots bandwidth bandwidth_stats bandwidth_stats_dbg refused fake_logs plugin_history'
BATCH_TABLES='pings certs nats spoof'
DATE=$(date -d "$CLEAN_DAYS days ago" "+'%Y-%m-%d'")
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment