feat: add logs

This commit is contained in:
HRG @ SCExC 2024-10-29 21:29:40 -04:00
parent c40bdcbbed
commit 305bf8b571
11 changed files with 690 additions and 468 deletions

View file

@ -0,0 +1,18 @@
CREATE TABLE logs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
error BOOLEAN NOT NULL,
structure_id INTEGER NOT NULL,
route_id INTEGER,
content TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY(structure_id) REFERENCES structures(id),
FOREIGN KEY(route_id) REFERENCES routes(id)
);
-- Trigger to update `created_at` on insert
CREATE TRIGGER update_logs_created_at
AFTER INSERT ON logs
FOR EACH ROW
BEGIN
UPDATE logs SET created_at = CURRENT_TIMESTAMP WHERE id = NEW.id;
END;