finished with the beginning of the database.

This commit is contained in:
Tristan Ancelet 2023-05-09 21:40:58 -05:00
parent 6a23079126
commit dc3ec782c7

View File

@ -25,7 +25,30 @@ CREATE VIEW IF NOT EXISTS log_statistics AS
GROUP BY logs.log_level_id;
CREATE VIEW IF NOT EXISTS log_statistics_last_7_days AS
SELECT log_levels.log_level_name, COUNT(logs.log_id) FROM logs
SELECT log_levels.log_level_name, COUNT(logs.log_id) as count FROM logs
JOIN log_levels ON log_levels.log_level_id = logs.log_level_id
WHERE logs.log_entry_timestamp > DATETIME(CURRENT_TIMESTAMP, '-7 day')
GROUP BY logs.log_level_id;
CREATE TABLE IF NOT EXISTS job_history (
job_id INTEGER PRIMARY KEY AUTOINCREMENT,
job_source TEXT NOT NULL, -- This will be the path to the script
job_result VARCHAR(7) NOT NULL, -- will be N/A, Fail or Success
job_exit_code INTEGER NOT NULL,
job_timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
);
CREATE VIEW IF NOT EXISTS last_ten_failed_jobs AS
SELECT job_timestamp, job_source, job_exit_code FROM job_history
WHERE job_result = "Fail"
ORDER BY job_timestamp DESC
LIMIT 10;
CREATE TABLE IF NOT EXISTS crontabs (
crontab_id INTEGER PRIMARY KEY AUTOINCREMENT,
crontab_path VARCHAR NOT NULL UNIQUE, -- this will be the parent directory of the crontab file
crontab_created_timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
crontab_modified_timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
crontab_data BLOB NOT NULL
);