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;
